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

Expand all Items in Hierarchical Grid (Editmode inline)

1 Answer 186 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lars
Top achievements
Rank 1
Lars asked on 09 Dec 2013, 04:44 PM
Hi Telerik,

i am searching for the best approach to expand all items in a grid.

It is a 5 Level hierarchy with dynamically created columns, which should be set in editmode.

The ItemCreated and Databound Event have to be fired.

Do you have a simple way to do this?

Thanks for helping!

KR

Lars


At the moment i set all items of the first level in editmode and expand the first level.
For expanding i use following code:
protected void RadGridHierarchy_PreRender(object sender, EventArgs e)
{
            if (_expandedItem != null && _expandedItem.Expanded)
            {
                if (_expandedItem.HasChildItems)
                {
                    foreach (GridTableView view in _expandedItem.ChildItem.NestedTableViews)
                    {
                        foreach (GridDataItem item in view.Items)
                        {
                            item.Edit = true;
                        }
                        view.Rebind();
                    }
                }
            }
 
            //Edit on all Items in Level 1
            for (int i = 0; i < RadGridHierarchy.MasterTableView.Items.Count; i++)
            {
                RadGridHierarchy.EditIndexes.Add(i);
                RadGridHierarchy.EditIndexes.Add(RadGridHierarchy.MasterTableView.Items[i].ItemIndex);
            }
}
 
 
protected void RadGridHierarchy_ItemCommand(object sender, GridCommandEventArgs e)
{
        if (e.CommandName == RadGrid.ExpandCollapseCommandName)
        {
                _expandedItem = (GridDataItem)e.Item;
                SaveGridValues();
 
                if (_expandedItem.Expanded)
                {
                    _expandedItem = null;
                }
        }
}

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 12 Dec 2013, 02:31 PM
Hello Lars,

You can use the following property to expand all items:
<telerik:GridTableView ... HierarchyDefaultExpanded="true">
Or expand/collapse all in-built functionality:
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/declarative-relations/defaultcs.aspx

For traversing the items and putting them on edit mode:
http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html

In case you are using In-Place:
http://www.telerik.com/help/aspnet-ajax/grid-put-all-items-in-edit-mode-no-additional-rebind.html
http://www.telerik.com/help/aspnet-ajax/grid-traversing-detail-tables-items-in-grid.html

Finally, I suggest you to check the new Batch edit feature provided by RadGrid:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx

Hope this helps.

Regards,
Eyup
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
Lars
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or