Hi,
Please see the attached example, if you click on the "Apply Layout" first and then click on "Add items" button then you'd see the column sorting breaks, but if you comment Sort function in CollectionOnCollectionChanged function on line 25 then sorting does not break, the first column is sorted correctly, can you please explain this behavior?
Also in the same example if i reset issorted to None first and then set the sort order then i see there are four items added insted of three. update the two functions in the previous example then click the update layout button and then additems button, you'll see 4 rows in the grid instead of 3
private void AddItems(object sender, RoutedEventArgs e) { collection.Add(new Data() { Data1 = "Item 1"}); collection.Add(new Data() { Data1 = "Item 2" }); collection.Add(new Data() { Data1 = "Item 3" }); }
public void Sort()
{ var t = grid.Columns[0] as TextColumn; t.IsSorted = SortDirection.None; t.IsSorted = SortDirection.Ascending; }
HI,
I have replicated your first sort issue.
What version and Build are you using?
Sincerely,
matt Developer Support Engineer
I am using build # 12.2.20122.2204
I will bring both issues to the attention of the developers
1) sort being lost when adding new rows to an empty grid
2) duplicate row added.
I will create a private case and email you shortly.
Matt
Developer Support Engineer
Hi I am facing the same problem. where I use a collection source and set the IsSorted from Xaml, but the sorting is not maintained after the collection gets new rows.
I am using version: 13.2.20132.1000. Can you tell me if it is fixed in this version?
Thank you,
Karthik.
That solves my problem. Thank you.
Hello Karthik,
It appears when binding to a CollectionView the grid is ignoring the initial setting for the IsSorted property if set in the XAML. Since the grid uses the SortDescriptions of the CollectionView you can achieve the initial sort by adding the SortDesription to the CollectionView and this will be carried over to the grid. I tested this using build 13.2.20132.2036 and when initially sorting the data via the collection view any additional rows added to the collection / grid were also sorted.
As far as the grid ignoring the IsSorted property when set in the XAML, I have asked our engineering team to look into this further. To ensure that it will receive attention, I have logged this behavior in our internal tracking system with a Development ID of 162646. The next step will be for a developer to review my investigation and confirm my findings or to offer a fix, or other resolution.
I have created a private case, CAS-130634-B3N7T2, for you to track this issue and notify you of any changes in the status of this issue. You may access this case at https://es.infragistics.com/my-account/support-activity.
Please let me know if you have any questions.
Valerie
Developer Support Supervisor - XAML
Infragistics
www.infragistics.com/support
I set IsSorted="Descending" on the TextColumn of an Integer field in Xaml, and bind a collectionviewsource object to the grid. The data is dynamic, after the initial list that loads on constructor of viewmodel, the rest of the data is filled in as they arrive from server. Although the initial data seems to be sorted correctly, the data that comes in later on don't get sorted properly.
I don't have much time to investigate any further. Would be great if you can do and check what is happening here. Here is one way I got it to work: I added a flag on the xaml code behind and reset the IsSorted in the InitializeRow event of the XamGrid if the flag is not set and then set it again so the IsSorted is not set again and again.
The original issue on this thread turned out to be an issue with the binding in the sample as opposed to the controls.
You mention you are having an issue when you set IsSorted in your grid are you using the XamGrid as opposed to the XamDataGrid?