Datagrid sorting

Marcello Bertoli mbertoli at libero.it
Fri Apr 23 06:25:52 CDT 2010


Hi Andre,

thanks again for your kind interest in solving this tricky issue.

I tried your code but the result is the same. It automates the process of clicking on two column headers.

What I would like to accomplish is different. I would like to sort with more than one criteria my datagrid rows when I click the header of the column date. Here there is an example of the scenario I would like to accomplish (look at the first two rows in both examples:

Number           Date                Customer
1               01/01/2010          aaaaaa
2               01/01/2010          bbbbbb
3               01/01/2010          cccccccc
4               02/01/2010          aaaaaaa
5               02/01/2010          bbbbbbb

I would like that when I sort by date, the data can also by sorted by (for example) customer (On the same date, the data must sorted alfabetically by Customer)

With your code (or with the default sorting code of datagrid) the result is this:

Number           Date                Customer
2              01/01/2010          bbbbbb
1               01/01/2010          aaaaaaa
3               01/01/2010          cccccccc
4               02/01/2010          aaaaaaa
5               02/01/2010          bbbbbbb

I can accomplish what I need querying the database with something like:

select number, date, customer from invoices order by date asc, customer asc

I think that, apart from the sql query, there are two chances:

1. The datagrid code can itself manage muti criteria sorting (maybe here Trevor can give us a hint)
2. We have to process the array of the datagrid, sorting with multicriteria and then populate again the datagrid with the new array.

Any idea?

Best regards
Marcello


More information about the use-livecode mailing list