Hi,
I create a Data grid in XAML with several fields, among them is FieldA and FieldB. A is added first to the layout, then B.
Now I define a sorting in XAML, adding first a FieldSortDescription for FieldB then one for FieldA. I would expect that the grid is first sorted according to B, then with A. But the sorting that happens ignores the sorting order of the fields and uses the layout order of the fields (first A then B).
How can I keep my layout order and change the sorting order?
Thanks and regards,
Bettina
Hello Bettina,
I have been looking into your issue and think have found out what is amiss here. While following your description and trying to reproduce your issue I got mixed up in the sorting as well. If we name your FieldA – Name and FieldB – Number I understand you would like to have something like this:
In order to achieve this you have to add the sorting for FieldB before the one for FieldA. In my case:
xamDataGrid1.FieldLayouts[0].SortedFields.Add(new FieldSortDescription("Number", ListSortDirection.Descending, false));
xamDataGrid1.FieldLayouts[0].SortedFields.Add(new FieldSortDescription("Name", ListSortDirection.Descending, false));
or
<igDP:FieldLayout.SortedFields>
<igDP:FieldSortDescription FieldName="Number" Direction="Descending" />
<igDP:FieldSortDescription FieldName="Name" Direction="Descending" />
</igDP:FieldLayout.SortedFields>
And if you want this:
Just switch their order. If you want to have the grid sorted to a single Field just leave one of the FieldSortDescriptions in the SortedFields collection.
Hope this clarifies things. Please try this on your end and let me know if everything is working ok.
Looking forward to hearing from you.
Sincerely,
Petar Monov
Developer Support Engineer
Infragistics Bulgaria
www.infragistics.com/support