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

ExpandCollapseAll expands but does not collapse in 2013Q3

3 Answers 50 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 07 Nov 2013, 03:58 PM
I've used this code to toggle a grid's expand-collapse state, but since installing the recent 2013 Q3 update the grid expands ok but then remains expanded when the expand/collapse command is triggered again. How do I collapse an expanded grid now?
if (e.CommandName == "ExpandCollapseAll")
{
    grid.MasterTableView.HierarchyDefaultExpanded = !grid.MasterTableView.HierarchyDefaultExpanded;
    grid.Rebind();
}

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Nov 2013, 09:11 AM
Hi Paul,

The requested functionality of Expand/CollapseAll is in-built from the 2013 Q2 release version of RadControls. Set the EnableHierarchyExpandAll="true" property for the Radgrid. Please check this demo on Grid - Expand All for Hierarchy.

Thanks,
Princy



0
Paul
Top achievements
Rank 1
answered on 08 Nov 2013, 01:59 PM
Thank you. I added e.Cancel = true to my code now that you explained the Telerik code now processes that command automatically. I did not see that listed under breaking changes in the 2013 Q3 release notes, which would have been helpful.

I kept my own code because I include both an expand/collapse icon and a text link in the grid's command item. I don't think the icon alone would be clear to all of my users. Is there a way to include both the icon and either text or at least a tooltip to make the meaning clear to users if I use the new automatic capability?
0
Kostadin
Telerik team
answered on 12 Nov 2013, 08:30 AM
Hello Paul,

You could add a text and tooltip by using the following approach.
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridHeaderItem)
    {
        GridHeaderItem header = e.Item as GridHeaderItem;
        Label label = new Label();
        label.Text = "Expand all items";
        header["ExpandColumn"].Controls.Add(label);
        Button button = header["ExpandColumn"].Controls[0] as Button;
        button.ToolTip = "Expand all items";
    }
}

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Paul
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or