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
185
Forcing SortStatus Feedback
posted

 Hi all,

We have intercepted the Sorting routed event from the xamDataGrid in order to carry out server-side sorting at the database. This is so we can show paged data, but sorts occur across all of the data in the table, shown or not.

So, we cancel the routed event (e.Cancel = true), handle the event to maintain WPF best practices (e.Handled = true), and then through our own logic we null the grid's data source (xamDataGrid.DataSource = null), perform a sort on the database table using the ListSortDirection object passed through in the DataPresenter.Events.SortingEventArgs as a reference of what we're sorting, and when we have a new set of data, we bind this to the grid again (xamDataGrid.DataSource = myNewEnumerableObject) and the grid shows server-side-sorted data.

 What we're struggling with now is reflecting the sort direction in the xamDataGrid.

The SortStatus of the field never gets updated so we can't just slap a DataTemplate on the LabelPresenter (the sort information isn't present to use DataTriggers with)on the field, and this property is ReadOnly, so we can't override. And I'm loathe to sort at the database and then augment the SortedFields collection either because we already have to persist our own sort information higher up the stack (field name, direction), and if this ever got out of sync then the sort behaviour would be broken and would look horrible.

 I suppose I'm asking either for a better solution to our overridden sort mechanism, or if there could be a way of overriding the SortStatus on a Field (or even just forcing a Label to show the sort asc/desc arrow) that would work.

 Any ideas guys?

 Many thanks in advance for helpful responses.

Parents
No Data
Reply
  • 30945
    Offline posted

    Hello,

     

    It has been a while since you have made your  post, in case you still need of support I will be glad to help with this matter. I suppose the other community members can benefit from this answer as well.  So I have created a sample application that demonstrates an approach for showing the SortIndicator when a Field’s header is clicked. In order to do that I created a template for the LabelPresenter, using the default style as basis in order to keep its original functionality.

     

    If you need any further assistance please do not hesitate to ask.

     

    Sincerely,

    Krasimir

    Developer Support Engineer

    Infragistics

    www.infragistics.com/support

     

    LabelPresenterTemplating.zip
Children
No Data