Hi,
We are running 2010.03, grid with 40 rows out of which only 3 rows has data in it.
When I sort (by clicking on the field) it brings up the blank rows first, meaning it includes all the blank rows while sorting.
What is the best approach to resolve this so to avoid blank rows being included while sorting.
Thanks,
Muthu
Hello,
I try providing custom SortComparer that doesn't help much.
However by handling Sorting and CellUpdated event together I am able to work around with this issue. (please see below code - I had to initialize the SortCol to MaxValue for it to be at the bottom when ascending with blank rows)
Does this make sense or a better approach is available in 2010.03.
Also it would be great if we get notified when a record been included for sorting so we can invalidate that if the record is not a vaild one for sorting. That would eliminate this approach of adding new column and handling cell updated event which I am not confortable with it as I think handling cell update just for this impact any performance?
Any thoughts?
private void XamDataGrid1Sorting(object sender, Infragistics.Windows.DataPresenter.Events.SortingEventArgs e) { if (e.SortDescription != null && e.SortDescription.Direction == ListSortDirection.Ascending) { e.Cancel = true;
e.FieldLayout.SortedFields.Clear();
e.FieldLayout.SortedFields.Add(new FieldSortDescription("SortCol", e.SortDescription.Direction, false));
e.FieldLayout.SortedFields.Add(new FieldSortDescription(e.SortDescription.FieldName, e.SortDescription.Direction, e.SortDescription.IsGroupBy)); } }
private void xamDataGrid1_CellUpdated(object sender, Infragistics.Windows.DataPresenter.Events.CellUpdatedEventArgs e) { var testViewModel = e.Cell.Record.DataItem as TestViewModel;
if (testViewModel != null && testViewModel.SortCol != int.MinValue) testViewModel.SortCol = int.MinValue; }
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.