Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Custom sorting using xamdatagrid
posted

hi,

i'm providing a custom sorting logic using the Sorting eventhandler and I can see that the bound datasource is being changed just after it exits the code block.   however, when rendered in the grid, it still uses its own sorting logic.  something similar to asp.net where there is some client side sorting happening in javascript which i want to disable.  setting to e.Handled true in the code doesn't help.

I was surprised though that when I have set e.Cancel in my eventhandler, my custom sorting logic is applied, however sorting is broken where clicking on the column header for the second time does not sort.  What I want to do is something similar to handling SortCommand only in asp.net grid and disabling the default sorting used by the grid.

  • 69686
    posted

    Hello,

    Canceling the Sorting event will stop the XamDataGrid from performing sorting.

    If you want to perform your own sorting, you can cancel the event (e.Cancel = true;) and then add your new FieldSortDescription object in the SortedFields collection of the FieldLayout.

    For example, the following code snippet handles and cancels the sorting event, and groups the XamDataGrid instead of just sorting it:

    void grid_Sorting(object sender, Infragistics.Windows.DataPresenter.Events.SortingEventArgs e)

            {

                e.Cancel = true;

                e.FieldLayout.SortedFields.Add(new Infragistics.Windows.DataPresenter.FieldSortDescription(e.SortDescription.FieldName,System.ComponentModel.ListSortDirection.Descending,true));

            }