Partial Refresh of Self Referencing GridView hierarchy

2 posts, 1 answers
  1. Alexis
    Alexis avatar
    1 posts
    Member since:
    Jan 2011

    Posted 04 Apr Link to this post

    I am looking to be able to change the structure of the parent child relationship in a self-referencing hierarchy without losing the currently expanded hierarchy not related to the rows/nodes being removed and replaced.

    I successfully have the ParentId and Id relationship displaying as a hierarchy in the grid view by using a BindingList<RowItemWithParentChildRelationship> bound to the DataSource of the RadGridView property.

    However when I remove the old rows/nodes that no longer apply and then add the new rows/nodes (to the BindingList<>) to be displayed the radgrid control only displays the old rows being removed and not the new rows that have subsequently replaced the old structure without offering the ability to expand into the new structure.

    Am I missing a trick to reparse the hierarchy (without losing the entire expand context) and display the newly added items in the hierarchy?

    I can update the DataSource property which off course rebuilds all rows and loses the currently expanded tree but if it is at all possible to avoid this it will make for a much better user experience.

    Digging around the available properties of RadGridView I've tried calling,

    radGridView.MasterTemplate.HierarchyDataProvider.Refresh();

    which I had hoped would reparse the bound data into the tree structure and offer the expansion into the replaced children of the parent node in question but to no avail.

    Many thanks in advance.

  2. Answer
    Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    711 posts

    Posted 05 Apr Link to this post

    Hello Alexis,

    Thank you for writing.

    I believe that you could achieve your task by saving the state of the expanded rows and after you change the data source object restore it. 

    I am sending you attached a sample project which I hope could fit your local setup.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top