Issues with placement of new row when using default sorting

7 posts, 1 answers
  1. Karen Grise
    Karen Grise avatar
    4 posts
    Member since:
    Aug 2009

    Posted 24 Aug 2011 Link to this post

    I have a grid that I'm binding to an ObservableItemCollection and a separate toolbar that allows the user to perform Add, Delete, etc. operations on the data within the grid. The data going into the collection is not sorted. I'm setting the default sort on a column in the code behind. When I add a new row using the toolbar button or hitting Insert the new row is added underneath the last record in the ObservableItemCollection, not the end of the grid where I'd expect it to be. So the new row could show up anywhere within the grid. If I don't set the default sorting, it puts the row at the end. Is there a way to force the row to be inserted after the last record within the grid?

    Also, I noticed when I don't set a default sort, then sort the grid on the client side I'm getting the same behavior. The insert it happening wherever the last item was put into the collection.

    Thanks,
    Karen
  2. Karen Grise
    Karen Grise avatar
    4 posts
    Member since:
    Aug 2009

    Posted 31 Aug 2011 Link to this post

    No one has ran into this? I wouldn't think that I would have to sort the observable collection or rebind when sorting within the code. That seems to be overkill. What I really need to know is how do I force the grid to insert a new record under the last row within the grid?

    Any help would be appreciated...

    Thanks,
    Karen
  3. UI for WPF is Visual Studio 2017 Ready
  4. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 03 Sep 2011 Link to this post

    Hello Karen Grise,

    RadGridView has special UI for adding new row, but it is over the rows just below the header row. You can easily show this row by setting RadGridView.ShowInsertRow = true. Unfortunately there is no way to move this row after the last item.
    Let me know if you need further assistance.

    Greetings,
    Nedyalko Nikolov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  5. Karen Grise
    Karen Grise avatar
    4 posts
    Member since:
    Aug 2009

    Posted 16 Sep 2011 Link to this post

    Thank you, Nedyalko, for your response. I don't want to display the ShowInsertRow. The way the user interacts with the grid is through a toolbar above the grid. When the 'Add' button is clicked, a new row gets inserted into the grid calling the BeginInsert() method. I don't want to move the ShowInsertRow to the last item. I just want to insert a new row at the bottom of the grid and when default sorting is set, it inserts the new row randomly. Is there anything else I can try?

    Thanks,
    Karen
  6. Answer
    Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 26 Sep 2011 Link to this post

    Hi Karen Grise,

    Sorry for the late reply.
    Unfortunately there is no way to this out-of-the box. There is a possible solution, which is a little bit tricky.
    The problem comes from the fact that RadGridView reacts on every NotifyCollectionChanged with respect to sorting and grouping, therefore item is displayed on its correct position (according to sorting) (indeed this could looks like random position but it is not). Keeping this in mind you can workaround this by sorting your data manually and use RadGridView just to show current sorting (without RadGridView to be sorted). Then you will achieve the desired "insert" behavior.
    For such example you can take a look at this online help topic.
    Let me know if this doesn't help.

    All the best,
    Nedyalko Nikolov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  7. Karen Grise
    Karen Grise avatar
    4 posts
    Member since:
    Aug 2009

    Posted 28 Sep 2011 Link to this post

    Hi Nedyalko,

    Thank you for responding. I understand what you're saying and you're right, the new row isn't randomly inserted. It would just appear to be this way to the user. As of right now, they're ok with it. I'll keep in mind yoyr suggestion and know that I have a workaround if the user's aren't happy with it.

    Thanks again,
    Karen
  8. Jason
    Jason avatar
    13 posts
    Member since:
    Jul 2010

    Posted 13 Jan 2012 Link to this post

    I've had a similar issue.  When I add a new row to a grid bound to an EntityObservableCollection and call OnPropertyChanged for the collection, the row sort order is not respected.  If a call SortDescriptors.Reset() the proper sort order gets applied, but I'm not sure what is the best event to handle to call this.
Back to Top
UI for WPF is Visual Studio 2017 Ready