Page 1 of 1

How can I group lists by a field?

Posted: Wed Mar 12, 2014 3:13 pm
by David Hunt

Here's an example:

My UI is a list inside a collapsible set. Let's assume that each entry takes input into 2 fields (state, city). So the database will look something like

Texas | Austin
Texas | Dallas
Georgia | Athens
Georgia | Atlanta

By default the the list is coming back like this:

Texas

  • Austin
    Texas

  • Dallas
    Georgia

  • Athens
    Georgia

  • Atlanta

    But I need it to be listed like this where state is a collapsible set item and each city is a list item within its state.

    Texas

  • Austin

  • Dallas
    Georgia

  • Athens

  • Atlanta

    Help please?


How can I group lists by a field?

Posted: Wed Mar 12, 2014 4:25 pm
by Nikita

Hello,

It might be helpful for you:
https://getsatisfaction.com/apperyio/...


How can I group lists by a field?

Posted: Wed Mar 12, 2014 7:36 pm
by David Hunt

I followed the examples in that link but it only applies to the list. It's still repeating the collapsible listing labels. Am I asking the wrong question? :/


How can I group lists by a field?

Posted: Thu Mar 13, 2014 2:12 am
by Illya Stepanov

Hi David,

You want to display hierarchical structure.

So to do this, you'll need to have hierarchical data return by your service.
For example, one of the items could be:
pre
{
stateName: "Texas",

Code: Select all

 cities: ["Austin", "Dalas"] 

}
/pre
To get this array in each row you can use "Array" column type.

You can take a look here for details: http://docs.appery.io/documentation/b... (search "Array" header in the document).

If you can't use "Array" column in your DB and the list service response you've described in first post, you can use "Generic Security Context" wrapper for your existing service.

Here is how to do it - http://docs.appery.io/documentation/g...

In this wrapper you can convert service plain response to hierarchical type.

So, after you get hierarchical data response, you can to do hierarchical mapping.

Please see screenshot for details: http://i62.tinypic.com/2126e7s.png