How can I sort a table?

Forums for specific tips, techniques and example code
basti
Posts: 13
Joined: Tue Oct 13, 2009 10:39 am

How can I sort a table?

Postby basti » Thu Oct 15, 2009 10:53 am

I have a collection presented in a table and I would like to have an option to select different sortings (e.g. a Customer-Collection --> option 1: sort by name; option 2: sort by ID and so on). How can I do that?

Thanks!

alanvl
Posts: 29
Joined: Fri Aug 14, 2009 9:16 pm

Re: How can I sort a table?

Postby alanvl » Thu Oct 15, 2009 12:10 pm

The Jade Table class has the following "sort" attributes (each is an array)
sortAsc, sortCased, sortColumn, sortType

The documentation is good at explaining each of these - note that the sort processing is limited to 6 columns

After setting the required attributes for your sort columns you will need to remember do a table.resort

basti
Posts: 13
Joined: Tue Oct 13, 2009 10:39 am

still not working

Postby basti » Thu Oct 15, 2009 2:22 pm

The Jade Table class has the following "sort" attributes (each is an array)
sortAsc, sortCased, sortColumn, sortType

The documentation is good at explaining each of these - note that the sort processing is limited to 6 columns

After setting the required attributes for your sort columns you will need to remember do a table.resort
Thanks for the help. The thing is, when I use this, when a collection is attached, it´s not working --> "This action is not valid when a collection is attached to a Control" :( .

Do I have to create more collections (key-dictionary) of the same class with different keys and then load the relevant collection?

User avatar
BeeJay
Posts: 312
Joined: Tue Jun 30, 2009 2:42 pm
Location: Christchurch, NZ

Re: How can I sort a table?

Postby BeeJay » Thu Oct 15, 2009 4:23 pm

"Do I have to create more collections (key-dictionary) of the same class with different keys and then load the relevant collection?"

If you want to populate the table using Table::displayCollection then yes, you have no choice but to have a collection keyed in the appropriate order for each of your column headings. Depending on your exact requirements, this collection does not have to be persisten but could be a dynamic dictionary, or indeed a dynamic external key dictionary, that you build as/when required. I've used dynamic external key dictionaries in the past to allow users to sort their tables by any of the columns using a "logical" external key for a colum that contains data of a type that does not sort "appropriately" using member key dictionaries.

Cheers,
BeeJay.


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 3 guests