We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How do you prevent clicking of the header from sorting the ggc

How to I disabled sorting in the grid from the UI. I want to prevent the grid from sorting when the user click on the header but still be able to do it programatically!

3 Replies

AD Administrator Syncfusion Team December 18, 2006 06:18 AM UTC

Hi James,

This can be achieved by setting the AllowSortColumns property to false. This disables the sorting of columns in User Interface, it also allows to sort programmatically. The following is the code snippet.

>>>>>>>>
// Form_Load event
this.gridGroupingControl1.TableOptions.AllowSortColumns = false; // Disable Sorting in UI
this.gridGroupingControl1.TableDescriptor.SortedColumns.Add("ParentName",ListSortDirection.Ascending);
>>>>>>>>

Also please refer to our shipped browser sample 'SortingMethods' [ \\windows\Grid.Grouping.Windows\Samples\Sorting\SortingMethods ] for more details.

Thank you for being patience.

Best regards,
Madhan


JB James Blibo December 21, 2006 02:59 AM UTC

Actually, my question was wrong... I want to selectively permit certain columns to be sortable and other to not be sortable. The solution that you provided is an all or nothing.


AD Administrator Syncfusion Team December 21, 2006 07:14 AM UTC

Hi James,

Thanks for your response. This can be achieved by handling the TableControlQueryAllowSortColumn event and cancel the sorting for the required columns.

Please try the following code snippet and let us know if you need any further assistance.
>>>>>>>>>>>>>>>>>Code Snippet 1<<<<<<<<<<<<<<<<<<<
// Form_Load Event
this.gridGroupingControl1.TableOptions.AllowSortColumns = true;
this.gridGroupingControl1.TableControlQueryAllowSortColumn += new GridQueryAllowSortColumnEventHandler(gridGroupingControl1_TableControlQueryAllowSortColumn);
// TableControlQueryAllowSortColumn Event
void gridGroupingControl1_TableControlQueryAllowSortColumn(object sender, GridQueryAllowSortColumnEventArgs e)
{
if (e.Column.Name == "Length")
e.AllowSort = false;
}
>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<

Have a nice day.

Best regards,
Madhan

Loader.
Live Chat Icon For mobile
Up arrow icon