Inserting row at any specified position

4 posts, 0 answers
  1. Ramyashree
    Ramyashree avatar
    29 posts
    Member since:
    Jan 2011

    Posted 16 Feb 2011 Link to this post

    Hi ,

      I'm having a gridview which is bound using domaindatasource... I can add new rows to the grid at it's end with minimal code (courtesy :raddomaindatasource).. However I want to be able to insert the row at any specified location as well... Any help regarding this will be appreciated...

    Thanks in Advance,
    Ramya
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 22 Feb 2011 Link to this post

    Hi Ramyashree,

    You can add a button to your page and when the user clicks it you can try the following:

    1. Create the new item.
    2. Call RadGridView.Items.Insert(index, item);

    I hope this helps.

    All the best,
    Ross
    the Telerik team
  3. DevCraft banner
  4. Ramyashree
    Ramyashree avatar
    29 posts
    Member since:
    Jan 2011

    Posted 22 Feb 2011 Link to this post

    I had tried it before itself..  In which case it will throw an exception saying that the Operation is invalid when Item Source is in use... Is there any other way of accomplishing it...?

    Thanks in advance,
    Ramya
  5. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 23 Feb 2011 Link to this post

    Hi Ramyashree,

    Please accept my apologies. It is my mistake. The thing that you want is not possible.

    Let me try to explain this.
    RadGridView adds items via IEditableCollectionView interface which has no Insert method. Another reason about such behavior is that this "new item" may not enter into RadGridView's ItemsSource collection (edit could be canceled). In your case with RadDomainDataSource after Submitting changes the new item will enter to the right position according to filtering, sorting and paging. You could also use our special UI for adding new items, just set radGridView.ShowInsertRow = true (which shows an insert row (area) at the top of the grid).
    Let me know if there is something unclear.

    Best wishes,
    Nedyalko Nikolov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top