Datagrid sorting

Andre.Bisseret Andre.Bisseret at
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  
    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  
    set the dgColumnSortDirection["date"] of grp "datagrid 1" to  
    set the dgColumnSortDirection["number"] of grp "datagrid 1" to  
## sort "number" first then "date"
    dispatch "sortByColumn" to grp "datagrid 1" with "number"
    dispatch "sortByColumn" to grp "datagrid 1" with "date"
end mouseUp

Best regards from Grenoble


More information about the Use-livecode mailing list