David Hunt
Posts: 0
Joined: Wed Mar 12, 2014 3:13 pm

How can I group lists by a field?

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?

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

How can I group lists by a field?

Hello,

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

David Hunt
Posts: 0
Joined: Wed Mar 12, 2014 3:13 pm

How can I group lists by a field?

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? :/

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

How can I group lists by a field?

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

Return to “Issues”