Page 1 of 1

Prevent data grid from sorting

Posted: Thu Nov 19, 2009 8:04 pm
by ibe
How can I stop a datagrid from sorting when the user clicks in the column header. Removing the header is not an option as I need them. I don't want the column header to sort but need them to allow resizing columns. If possible, it's not obvious from the docs.

Ismo

Prevent data grid from sorting

Posted: Thu Nov 19, 2009 11:21 pm
by dickey
Hello ibe,

Whilst not exactly answering your question, being able to reset sorting in the grid is related to your question and very useful especially when organising data before performing calculations on DataGrid values. It may negate the need to disable sorting, because you can reset whenever you like.

Code: Select all

on mouseUp
   -- reset sorting in grid
   set the dgProps["sort by column"] of group "DataGrid 1" to empty
end mouseUp
I have not had the necessity to disable sorting altogether, as I can restore/reset sort order before updates or other operations using the above method (and users love sorting), however I believe you may disable sorting by altering the column template of the DataGrid.

I hope this helps.

Kind regards, Andrew

Posted: Fri Nov 20, 2009 7:02 am
by ibe
Finally found the answer. Just in case anyone else needs it, the simple way is to add the below code to the data grid script:
on SortDataGridColumn pColumn
end SortDataGridColumn

This will prevent all columns from sorting and changing the header appearance. I found the answer here:
http://revolution.screenstepslive.com/s ... n-Sorting-

which seems interesting for those who need specialized sorting.