Datagrid sorting

Andre.Bisseret Andre.Bisseret at inria.fr
Wed Apr 21 13:33:20 EDT 2010


Bonjour Marcello,


Le 21 avr. 10 à 18:10, Marcello Bertoli a écrit :

> Hi all,
>
> I need to sort the lines of a datagrid with more than one criteria.
>
> For instance:
>
> The datagrid represents invoices with these columns:
>
> - invoice date
> - invoice number
> - invoice title
>
> When I click on the invoice date header I would like to sort the  
> lines of the invoice datagrid first by invoice date and then by  
> number.
>
> Is it possible?
>
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

HTH
Best regards from Grenoble

André






More information about the use-livecode mailing list