Hi,
I have the requirement to sort one field in my xamdatagrid descending on the first click on the label.
At the moment it requires two clicks as the field is sorted ascending first.
How can i achieve this?
I'm using version 14.1 with mvvm.
Best
Oliver
Hello Oliver,
Thank you for the feedback. I am glad that you have found a solution to your issue.
Got it:
<infr:FieldLayoutSettings SortEvaluationMode="Manual" />
protected override void OnSorting(SortingEventArgs e) { ICollectionView iCollectionView = (ICollectionView)DataSource; iCollectionView.SortDescriptions.Clear();
ListSortDirection direction = ListSortDirection.Descending;
string sortedInfo = e.Field.Name;
if (string.Equals(sortedInfo, "MySpecialColumn")) { if (e.SortDescription.Direction == ListSortDirection.Descending) { direction = ListSortDirection.Ascending; } } else { direction = e.SortDescription.Direction; }
iCollectionView.SortDescriptions.Add(new SortDescription(sortedInfo, direction)); }
Hi Gergana,
I tried to overwrite the OnSorting Event but it doesn't change anything. Can you fix it?
protected override void OnSorting(SortingEventArgs e) { string sortedInfo = e.Field.Name;
if (string.Equals(sortedInfo, "IsInvalid")) { if (e.SortDescription.Direction == ListSortDirection.Ascending) { ICollectionView iCollectionView = (ICollectionView)DataSource; iCollectionView.SortDescriptions.Clear(); iCollectionView.SortDescriptions.Add( new SortDescription(sortedInfo, ListSortDirection.Descending)); } else { ICollectionView iCollectionView = (ICollectionView) DataSource; iCollectionView.SortDescriptions.Clear(); iCollectionView.SortDescriptions.Add( new SortDescription(sortedInfo, ListSortDirection.Ascending)); } } else { base.OnSorting(e); } }
Thank you for your post!
I have been looking into it and what I can suggest is to take a look at the following forum thread where similar issue is discussed: http://ko.infragistics.com/community/forums/t/86888.aspx.
On this thread you would be able to find a sample application too.
Please do not hesitate to let me know if you have any further questions on this matter.