Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
285
How to apply the current sort to new rows
posted

Our application uses a xamGrid that is bound to an ObservableCollection.  As new objects are added to the collection they automatically show up in the grid -- wonderful.  The problem I'm having is that the newly added objects are always being appended to the end of the grid, even when the grid is sorted.  So, if I have a grid with two columns, first name and last name, and I'm sorted by last name I might see something like this:

Jane Apple

Joe Brown

Ashley Denver

Then, when Charlie Cooley is added to the ObservableCollection, the grid will look like:

Jane Apple

Joe Brown

Ashley Denver

Charlie Cooley

But since I'm sorted by last name, I need Charlie to be added between Joe Brown and Ashley Denver.  Make sense?  Any suggestions on how best to accomplish this?  I'm hoping there's just a property on grid somewhere that I'm missing.

 Thanks,

Mike.

  • 138253
    Offline posted

    Hello Mike,

    Thank you for your post. I have been looking through it and I suggest you add the following code:

    xamDataGrid1.Records.RefreshSort();

    after you add new items to the ObservableCollection. Calling this method guarantees you that every time you add new item to the ObservableCollection the XamDataGrid refreshes and you will have the desired result. Please note, we are making efforts to ensure all posts are addressed by an Infragistics expert. We believe that the other community members could benefit from this thread as well.

    Feel free to write me if you need further assistance.