Insert new row on desired position

11 posts, 1 answers
  1. Thiago
    Thiago avatar
    16 posts
    Member since:
    May 2012

    Posted 19 Feb 2013 Link to this post

    Hello,
    I want implement a GridView with the funcionality of add new entries on specific positions. For sample, the grid will be loaded with five static rows, and the user just can add a new row above it. This way, the new row created by the user can be deleted or a new row can be added above it again. So, basically is this: the pre-loaded rows are statics, can´t be deleted, and the new rows can be deleted or a new row can be created above it.
    How could I create a new row always above other row? In the nameOfGrid.BeginInsert() method the new row is created on the bottom of grid. 

    I´ve attached two images to demonstrate the desired behavior. The first one shows the static rows pre-loaded, just with the option to add a new row. The second shows a new row created on the bottom of grid, with the option to add and remove a row. 

    Thanks in advance,

    Thiago
  2. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 19 Feb 2013 Link to this post

    Hi,

     You cannot do that using BeginInsert() method of the grid. You should work directly with the collection bound to the grid. For example you can get the index of the current/selected item and use the collection Insert() method.

    Greetings,
    Vlad
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Thiago
    Thiago avatar
    16 posts
    Member since:
    May 2012

    Posted 19 Feb 2013 Link to this post

    For sure Vlad.
    Thanks by the light.
    This is what I was looking for.

    Greetings,

    Thiago
  4. Harshal
    Harshal avatar
    10 posts
    Member since:
    Jul 2013

    Posted 12 Nov 2013 Link to this post

    Please share the code to do above trick.
  5. Ed
    Ed avatar
    4 posts
    Member since:
    Feb 2014

    Posted 10 Feb 2014 in reply to Vlad Link to this post

    Can you provide a sample code to do what you just suggested?

    Thanks.
  6. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Feb 2014 Link to this post

    Hi,

    This is a sample code snippet illustrating the suggestion of my colleague:
    var index = this.clubsGrid.Items.IndexOf(this.clubsGrid.SelectedItem);
    clubs.Insert(index, newClub);

    Please note that clubs is the collection bound to RadGridView with name clubsGrid.

    Regards,
    Didie
    Telerik

    Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

  7. Shreya
    Shreya avatar
    18 posts
    Member since:
    Aug 2014

    Posted 13 Oct 2014 in reply to Dimitrina Link to this post

    Hi Dimitrina..
    I also want some similar kind of functionality...
    Need to Add one static row always at the bottom of all data in my radgrid irrespective of operation (sorting, grouping etc)
    The row will need to look similar as below. Pls let me know in case you have any approach. I cant use footer as there s a seperate text for footers.

  8. Shreya
    Shreya avatar
    18 posts
    Member since:
    Aug 2014

    Posted 13 Oct 2014 Link to this post

    Here is the screenshot for my problm
  9. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Oct 2014 Link to this post

    Hello,

    You could redefine the template of RadGridView and embed your own custom footer and define it as you wish. 
    Using Implicit Styles gives you the ability to easily extract and edit the default ControlTemplates of the controls. You can also follow this article on two different approaches on how to extract the ControlTemplates.


    Regards,
    Dimitrina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  10. Shreya
    Shreya avatar
    18 posts
    Member since:
    Aug 2014

    Posted 14 Oct 2014 in reply to Dimitrina Link to this post

    Thanks for the response.
    I cannot customize the footer of my grid, As I have some already data for footer. Can you suggest any other way to add just a static row at the end of all rows in grid as in the screenshot apart from footer.
  11. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 16 Oct 2014 Link to this post

    Hello,

    There is not a way to configure our control to just add a static row at the end of all rows, however, once you edit its template, you can modify it in any way you wish.

    Regards,
    Dimitrina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top