Page 1 of 1

How can I sort a table?

Posted: Thu Oct 15, 2009 10:53 am
by basti
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!

Re: How can I sort a table?

Posted: Thu Oct 15, 2009 12:10 pm
by alanvl
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

still not working

Posted: Thu Oct 15, 2009 2:22 pm
by basti
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?

Re: How can I sort a table?

Posted: Thu Oct 15, 2009 4:23 pm
by BeeJay
"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.