This works perfectly unless the user has grouped the records. When the records are grouped the new record is not added to the grid and the code to locate the record in the grid doesn't locate the new record.
I have also confirmed the grid DataLoaded event doesn't fire if the records are grouped but does fire otherwise. There are no filters applied to the grid.
What do I have to do to force the grid to load and display the record?
6 Answers, 1 is accepted
As I understand you observe the problem only when RadGridView is grouped. May I ask you to configure your RadGridView setting GroupRenderMode="Flat"?
Then, you say DataLoaded event doesn't fire. The DataLoaded event will be raised every time when a CollectionChanged notification is raised for RadGridView.Items collection. Such a notification will be raised every time a data operation like sorting, grouping or filtering is performed. The operation can be performed from the UI or in code.
So, this event should be raised every time you perform grouping.
May I ask you to confirm the version you are using?
I set GroupRenderMode to Flat as requested but this made no difference.
I placed a breakpoint in the code for the DataLoaded event and it does fire when;
- the collection is first added to the DataContext of the grid
- the grouping of the grid is changed
- an object is added to the collection AND the grid is NOT grouped
However the DataLoaded event does not fire if the grid is grouped and an object is added to the collection.
Following is a simplified example of the code I am using;
Line 30 will trigger the DataLoaded event if the grid is not grouped.
Please note the breakpoint is on line 2 not line 3 so my problem is not that line 3 doesn't execute it is that execution does not get to line 2.
I am currently using version 2014.1.224.40.
I am still not able to reproduce any issue at my side. I have attached my test project as a reference.
Would you please check it and modify it so that the issue to be observed?
In order to test it you should:
1. Run it
2. Group by any column
3. Click the button
5. Observe the value of the infoLabel, next to the button.
Let me know about the result.
You can find the test solution attached.
Thanks for your reply. I tried the example program you provided and it worked without any problems however I still haven't been able to get my code to work.
I modified the code as follows to provide some feedback on the problem;
The attached screens show the results of my testing as follows;
- Screen 1 shows the screen without any grouping but filtered to display a limited number of records.
- Screen 2 shows the screen after saving a new record (the green shading is a style applied to the grid to highlight records that have been add/modified in the current session).
- Screen 3 shows the screen with grouping applied and after saving the 2nd new record.
- Screen 4 shows the screen with the grouping removed (note the 2nd new record is now displayed)
The following is the output from the debug statements;
The entries for 10:08:34 show the statements executed from Screen 2 when the 1st object was added.
The entry for 10:10:23 is when the grouping was applied.
The entry for 10:10:38 is when the 2 object was added (but wasn't displayed in the grid).
The entry for 10:11:46 is when the grouping was removed and the record was then displayed. Any help you can provide on this would be greatly appreciated.
You can also subscribe for RadGridView.Items.CollectionChanged event and monitor if such an event is raised when a new item has been added.
How is your solution different than mine? Would you please try extending my test solution to be as close to your real case as possible?
According to this ticket's information you use version 2014.1.331, is this correct?