Preserve expand collapse state after rebinding data

6 posts, 0 answers
  1. arno koolen
    arno koolen avatar
    7 posts
    Member since:
    Jun 2008

    Posted 06 Jul 2008 Link to this post

    I have a RadGrid with 3 levels of hierarchy declared as below (some markup left out for readability)

    <telerik:RadGrid    ID="RadGrid1"   
                        runat="server"   
                        AllowSorting="True"   
                        Skin="Office2007"   
                        ShowStatusBar="True"   
                        GridLines="None"   
                        DataSourceID="SQLDataSource1"   
                        AutoGenerateColumns="False" 
                        EnableViewState="true">  
     
        <MasterTableView    HierarchyLoadMode="ServerBind"   
                            EnableNoRecordsTemplate="true"   
                            DataKeyNames="PartGroupID,PartGroupParentID"   
                            Width="100%"   
                            ShowHeader="true"   
                            AllowPaging="false">  
                                <SelfHierarchySettings  ParentKeyName="PartGroupParentID"   
                                                        KeyName="PartGroupID"   
                                                        MaximumDepth="10" /> 

    Users will expand/collapse and collapse the structure, but will also modify the data in the grid. When the data is modified, the RadGrid needs to rebind.

    RadGrid1.Rebind(); 

    Unfortunately when this happens the grid either collapses fully or expands fully depending on whether the

    <MasterTableView HierarchyDefaultExpanded="true" 

    is set or not.

    What I want is for the grid to maintain its expanded/collapsed state after rebinding, otherwise the user has to expand collapse the grid again to navigate back to node they were editing before the ReBind() was called.

    Is there any way to preserve the state, short of rolling my own code?


    Thanks,

    Malcolm
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Jul 2008 Link to this post

    Hi Malcolm,

    Here is a code library which explains how to retain the expanded state of the Grid on rebind. Go through it and see whether it helps.
    Retain expanded/selected state in hierarchy on rebind

    Thanks
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Alex
    Alex avatar
    16 posts
    Member since:
    Nov 2012

    Posted 30 Apr 2014 in reply to Shinu Link to this post

    shinu, the link you provided is dead.
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 01 May 2014 in reply to Alex Link to this post

    Hi Alex,

    You can take a look at this code Library on Retain expanded/selected state in hierarchy on rebind.

    Thanks,
    Shinu
  6. Eyup
    Admin
    Eyup avatar
    3012 posts

    Posted 05 May 2014 Link to this post

    Hi Alex,

    You can also use the following recently introduced property:
    <MasterTableView ... RetainExpandStateOnRebind="true">

    Hope this helps.

    Regards,
    Eyup
    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.

     
  7. Mousumi
    Mousumi avatar
    4 posts
    Member since:
    Sep 2015

    Posted 20 Nov 2015 in reply to Eyup Link to this post

    Great!!Working fine by just setting a single property
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017