This is a migrated thread and some comments may be shown as answers.

Collapse/Expand on edit

3 Answers 216 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Oxygen
Top achievements
Rank 1
Oxygen asked on 29 Jun 2009, 11:12 AM
Hi

I hoping that someone in here can help with with my problem.

I have a grid which are grouped and by default they should all be collapsed.

Then if i expand one group i get the items associated with that group. Thats fine.

Each item is editable and it uses a usercontrol to handle the editing.

BUT, when i press edit on an item (Im using code behind, so it makes postback) all group are now again collapsed.

I can make the clicked item appear in its group but not the whole group or nor the usercontrol to edit the clicked item in.

Any way to make this happen?

Thanks in advance

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Jun 2009, 11:36 AM
Hi Thomas,

I hope the the GridGroupHeader is getting collapsed once you click the edit button. If so you may try the following code snippet to keep the Grouped row expanded on performing edit.

CS:
 
  protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridGroupHeaderItem groupHeader in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader)) 
        { 
            GridItem[] children = groupHeader.GetChildItems(); 
            foreach (GridItem child in children) 
            { 
                if (child.Edit == true
                    groupHeader.Expanded = true
            } 
        } 
       
      
       
    } 


Regards
Shinu.
0
Oxygen
Top achievements
Rank 1
answered on 29 Jun 2009, 02:38 PM
Hi Shinu,

Thanks for the answer.
That was very helpful and I almost got it.

Now the whole group is expanded but i can still not see my editform which is a usercontrol I load from codebehind on "OnItemCommand".

If I add GroupsDefaultExpanded = false the group are collapse when the page opens and when i Expand one group the others are still collapse.
The problems is just that when I use this setting my editform wont show up and if I switch to GroupsDefaultExpanded = true or not adding it at all my form shows but the other groups are also expanding.

Any way i can my form appear? or collapsing the other groups without use the mentioned setting.

Thanks again
0
Sebastian
Telerik team
answered on 02 Jul 2009, 10:54 AM
Hi Thomas,

Indeed when you choose GroupsDefaultExpanded = true (default value for this property) the grid groups will be shown as expanded on initial load and when you edit an arbitrary grid item. This behavior is by design.

If you would like to have several groups expanded and keep their state on edit action, you may consider Shinu's approach or the solution presented in the code library thread linked below:

http://www.telerik.com/community/code-library/aspnet-ajax/grid/persist-groups-expanded-state-on-rebind.aspx (note that the edit operation triggers implicit rebind for the grid)

Also verify that you have set GroupLoadMode to Server when using the second approach.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Oxygen
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Oxygen
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or