Datagrid sorting

Andre.Bisseret Andre.Bisseret at inria.fr
Thu Apr 22 14:35:54 EDT 2010


Marcello,

Seems this one might be working as you expected (?)

-- in the script of the dataGrid: -------

local hcColumn,theColumn
-------
on mouseDown
    put the dgHeaderControl of the mouseControl into hcColumn
    if hcColumn is not empty then
       put the dgColumn of the target into theColumn
       if theColumn is "date" then
          dispatch "sortByColumn" to the target with "date"
          wait 1 sec
          set the dgColumnSortDirection["number"] of the target to  
"ascending" -- may be not necessary
          dispatch "sortByColumn" to the target with "number"
       end if
    end if
end mouseDown
----------

best
André




Le 22 avr. 10 à 11:38, Marcello Bertoli a écrit :

> 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
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution






More information about the use-livecode mailing list