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
285
How to invoke a manual sort
posted

We're writing an application for a non-computer savvy user base.  As a result I need to add a "Default Sort" button to our UI that will manually sort our xamGrid by multiple columns (we can't expect our users to know ctrl+click on multiple columns).  Is there a way I can invoke a call to sort on the grid and provide an IComparer?

 Thanks,

Mike.

Parents
  • 4850
    Verified Answer
    Offline posted

    Hi Mike,

    The FieldSettings object exposes SortComparer and SortComparisonType properties. You can then specify the sorting criteria thru the FieldLayout's SortedFields collection e.g.

    Field fld =  this.xamDataGrid1.FieldLayouts[0].Fields["CustomerName"];

    fld.Settings.SortComparisonType = FieldSortComparisonType.CaseInsensitive;

    FieldSortDescription fsd = new FieldSortDescription();

    fsd.Field = fld;

    fsd.Direction = "Descending";

    this.xamDataGrid1.FieldLayouts[0].SortedFields.Add( fsd);

Reply Children