Add row in a hierarchy structure

3 posts, 1 answers
  1. Cristina
    Cristina avatar
    3 posts
    Member since:
    Nov 2018

    Posted 18 Jun 2020 Link to this post

    I have a radgridview element where I need to programmatically insert a new row into the child structure of a certain parent row. The behavior would be the same as if I add a row from the add new row (UserAddNewRow). The final result should be equivalent to the row 'NEW ROW' in the attached image.

    Thank you.

  2. Answer
    Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    4170 posts

    Posted 19 Jun 2020 Link to this post

    Hello, Cristina,  

    According to the provided information, it is not clear enough whether you are using RadGridView in bound or unbound mode and how exactly the hierarchy is set up. Could you please elaborate?

    Without knowing the exact setup, I can give you only general suggestions how to add a new row to the child level. 

    If you set the DataSource property (bound mode) for each GridViewTemplate (master level and child level), in order to add a new record for the child template, it is necessary to add a new record to the DataSource collection that is being applied to the child GridViewTemplate. Since there is a relation (GridViewRelation) between the two GridViewTemplates indicating the child ID and the parent ID, it is important to specify the proper parent ID for the new record. Thus, the hierarchy row will be added to the respective parent row.  A sample approach how the hierarchy is setup in this case is available in the "Setting the hierarchical grid in bound mode" section in the following help article: 

    If you use unbound mode and you add the rows directly to the Rows collection of the respective GridViewTemplate, it is just necessary to add a new row which cell's value for the parent ID points to the desired parent row. A sample approach for this approach is demonstrated in the "Hierarchical Grid in Unbound mode" section in the above referred article.

    However, if you are still experiencing any further difficulties, it would be greatly appreciated if you can give us some more details about the precise case. A sample code snippet how you setup and populate the grid with hierarchical data would be greatly appreciated. Thus, we would get better understanding of the precise case and think about a suitable solution.

    I hope this information helps. If you need any further assistance regarding the Telerik UI for WinForms suite please don't hesitate to contact me. 

    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  3. Cristina
    Cristina avatar
    3 posts
    Member since:
    Nov 2018

    Posted 02 Jul 2020 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thank you very much for the detailed answer. It has solved the problem for me.
Back to Top