
I have a RadGridView bound to ObservableCollection. This collection is constantly updated and on first binding the grid represent the data correctly. But then I click on one of the headers to sort the data in the grid. After that behaviors on adding a new row become as following:
- the grid adds the row to the end of the list only, it doesn't sort data dynamically according sorting column;
- sometimes (often) the grid creates duplicate rows while underlying collection contains correct data;
I couldn't find in documentation any info that I should programmatically sort underlying collection each time after adding row or rebind it every time so the grid shows it correctly. What should I do to fix it or it\s a norm for Telerik Grid?
9 Answers, 1 is accepted
RadGridView should work as expected in such scenarios. I have tried to reproduce the issue with a test application but everything worked just fine. Maybe the application doesn't exactly match your scenario. Could you please take a look at the attached application and try to reproduce the problem?
Thank you for your time.
Best wishes,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

Milan. thank you for your reply. Your sample works and for every field! Not for “Number” only! Well… I modified your sample to make it easier from one side and injected some logic to make it close to real life. I removed Club class as we need the sample clearly but it’s just cosmetic changes. Then I implemented logic that adds, removes and updates items in the collection on each “button click”. In result what we have? The Grid is able to sort the data by Integer (ie “Number”) field only!!! It doesn’t sort by any other field automatically!
What’s wrong?
ps/ the project solution i'll try to send via ticket
Thank you! denis
Thank you for sending a sample project. I noticed that you change some properties in the performPlayers() method. Unfortunately if you change a property using code and grid is sorting by that property the data will not be reordered to reflect the new property change. The ObservableCollection can help in situation where items are added/removed/moved/replaced but not in situation where item properties are changed.
To handle such situation you can call the Rebind method of RadGridView right after data items are changed:
private
void
Button_Click(
object
sender, RoutedEventArgs e)
{
players.performPlayers();
this
.playersGrid.Rebind();
}
Best wishes,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

the strange thing is that changing "integer" typed property is not required to rebind grid and it sort tows as requred. Any proper solutions?
Thank you
denis
The grid will not be refreshed automatically no matter if the property is integer or not - you can use however our ObservableItemCollection and call Reset when needed to achieve your goal.
I've attached an example project demonstrating RadGridView sorted descending on integer property and refreshed every millisecond.
Best wishes,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

Indeed, in my example the grid sorts the data automatically if Number (“integer type”) column selected for sorting! It doesn’t require rebind! But you said it does’t….
I can’t use your ObservableItemCollection because I already use my “special” ObservableCollection which can dispatch events to UI from multi-threads environment informing grid on propertyChanging. RadGrid should handle this and it handles in simple situations like on adding items only…. but it doesn’t support as I can see the basic functionality that any grid should support ie sort items according required columns upon item changed is sortProperty is set…
Now I should think how to propagate CollectionChanged event from the thread to RadGrid so it could re-bind or somehow resort the content…
Thank you
denis

Upgraded wpf from 09q3 to 10q1 (vs2008) and tested today.
Currently in the application I use the one instance of the grid which rebinding to different sources therefore AutoGenerateColumns="True" and no any column definitions and soft definitions.
In the previous version (09q3) when I selected a column for sort and then changed the source the application crashed if it couldn’t find the same sort column in new source. Now as I can see it was fixed and app continue running.
The most interesting thing is that now all columns are sorted automatically, even when property updated (not only ne items added). At least it sorts string and int and decimal columns (properties).
Well.. the question is if Telerik developer is not sure of the grid behaviors how I can sure that in the next release all these behaviors stays the same?
Thank you for your help!
denis
The application attached to this thread is using actually our Q1 2010 binaries.
All the best,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

You said that if I change a property using code and grid is sorting by that property the data will not be reordered to reflect the new property change.
Is it still necessary to rebind the grid when the property is changed?
Thanks!