How Do I Disable Column Sorting?
This lesson will show you how to disable column sorting in a Data Grid table.
To begin, make sure you set the sort by column property to empty. This will remove any column sorting that might be active.
set the dgProp["sort by column"] of group "DataGrid 1" to empty
Your table headers should now appear the same, with no highlights or sorting arrow.
Edit the Data Grid group script by right clicking on the Data Grid and selecting Edit Script.
When the user clicks on a table column header the SortDataGridColumn message is sent to the Data Grid. By intercepting the message and not passing it you will effectively disable sorting. For more information about how SortDataGridColumn works please see this lesson.
Add the following code to your Data Grid group script and compile.
Copy & Paste
on SortDataGridColumn pColumn end SortDataGridColumn
Now when you click on the table header the data will not be sorted.
Note: Once you add the SortDataGridColumn handler to a Data Grid setting the dgProp["sort by column"] property will no longer do anything. If you need to set the "sort by column" property later on you would need to remove the SortDataGridColumn handler from the script, or at least pass the message.