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

[Solved] Problems with detail table collapse and edit mode

2 Answers 173 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stefan
Top achievements
Rank 1
Stefan asked on 26 May 2009, 04:11 PM
Hi,

we've a grid with 3 levels. The second and third levels are set to edit mode in the prerender event of the grid.
The problem is, that it is possible to expand these levels. but collapsing doesn't work anymore?!

Here is the sample code:

protected void RadGridContractProducts_PreRender(object sender, EventArgs e) 
        for (int i = RadGridContractProducts.MasterTableView.GetItems(GridItemType.NestedView).Length - 1; i >= 0; i--) 
            { 
                for (int j = ((GridNestedViewItem)RadGridContractProducts.MasterTableView.GetItems(GridItemType.NestedView)[i]).NestedTableViews.Length - 1; j >= 0; j--) 
                { 
                    
                    SetItemsMode(((GridNestedViewItem)RadGridContractProducts.MasterTableView.GetItems(GridItemType.NestedView)[i]).NestedTableViews[j]); 
                } 
            } 
 
 
            RadGridContractProducts.Rebind(); 
        } 
 
private void SetItemsMode(GridTableView oGridTableView) 
        { 
            for (int i = oGridTableView.Items.Count-1; i >= 0; i--) 
            { 
                 
                oGridTableView.Items[i].Edit = true
 
            } 
 
            
            for ( int i = oGridTableView.GetItems(GridItemType.NestedView).Length -1; i >=0 ; i-- ) 
            { 
                for ( int j = ( ( GridNestedViewItem )oGridTableView.GetItems(GridItemType.NestedView)[i]).NestedTableViews.Length -1 ; j >=0; j--) 
                { 
                    SetItemsMode(((GridNestedViewItem)oGridTableView.GetItems(GridItemType.NestedView)[i]).NestedTableViews[j]); 
                } 
 
            } 
        } 

Could someone explain how to get this problem solved?

Thanks in advance

Stefan

2 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 29 May 2009, 10:39 AM
Hello Stefan,

This approach and functionality should not break the expansion functionality of the nodes. Based on this information and code snippet, however, it is hard to determine what is the cause of the problem. If the issue persists, you can open a formal support ticket, and send us the problematic implementation for additional testing and research.

All the best,
Yavor
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.
0
Thuan
Top achievements
Rank 1
answered on 28 Jan 2010, 05:00 PM
Stefan,

I was able to get the expand/collapse to work with by adding the following code to the ItemCommand event handler:

        void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
            var commandName = e.CommandName;

            if (commandName == "ExpandCollapse")
            {
                if (e.Item.Expanded == true)
                {
                    e.Item.Expanded = false;
                    e.Item.OwnerTableView.Rebind();
                    e.Canceled = true;
                }
            }        
        }

I have a grid with 3 levels also.  My problem now is how to put the MasterTableView in edit mode, level 2 in normal mode, and level 3 in edit mode and have the expand/collapse work accordingly.  Currently, any views not in edit mode does not expand.

Thanks in advance.
Tags
Grid
Asked by
Stefan
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Thuan
Top achievements
Rank 1
Share this question
or