Datagrid sorting

Marcello Bertoli mbertoli at libero.it
Thu Apr 22 05:38:47 EDT 2010


Hi Andre,

thank you very much for your answer. I tried your code but it doesn't do the job. It is like pushing the column header of the datagrid two times (first the number one and the the date one).

My data come from a sql base so I can (as Steven said) make the query do the work of the multiple sorting before loading into the datagrid but I'm scared about performances when it comes to manage hundreds of thousands of data. In this scenario I need to retrieve data from the sql base and then populate the datagrid every time I need to sort the rows without the data I already have in the datagrid. This means more traffic over the network and multiple populations of the datagrid...

Best regards
Marcello



On 21/apr/2010, at 19.33, Andre.Bisseret wrote:

> I think yes! Assuming for instance you want the dates sorted from the oldest down to the more recent
> and then, for each date, the numbers should be sorted from the smaller down to the greater
> you should sort the numbers column first then the dates' column.
> Something like that:
> 
> on mouseUp
> ##setting the sort type value for each column
>   set the dgColumnSortType["date"] of grp "datagrid 1" to "system dateTime"
>   set the dgColumnSortType["number"] of grp "datagrid 1" to "numeric"
>   set the dgColumnSortType["title"] of grp "datagrid 1" to text
> ## making sure the two columns will have the same sortDirection if necessary
>   set the dgColumnSortDirection["date"] of grp "datagrid 1" to "ascending"
>   set the dgColumnSortDirection["number"] of grp "datagrid 1" to "ascending"
> ## sort "number" first then "date"
>   dispatch "sortByColumn" to grp "datagrid 1" with "number"
>   dispatch "sortByColumn" to grp "datagrid 1" with "date"
> end mouseUp



More information about the use-livecode mailing list