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

Getting back to where I was.

2 Answers 38 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stuart Hemming
Top achievements
Rank 2
Stuart Hemming asked on 04 Jul 2010, 12:43 AM
I have a grid with a MasterTable and a DetailTable.

There are times in the life of my app when I have the DetailTable open on a particular row of the MasterTable and I do something that requires the grid to be rebound.

I know the MasterTable row index and the row index on the DetailTable.

After I have rebound the grid, how can I get the grid to expand the relevant MasterTable row, populate the DetailTable and select the relevant row in it?

The best I could come up with is something like this...
RadGrid1.MasterTableView.Items[MasterTableRowIndex].ChildItem.Expanded = true

Sadly this doesn't do what I thought it might.

Anyone have any clues?

-- 
Stuart

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 05 Jul 2010, 09:41 AM
Hello,

I hope the code shown below helps you in this.

C#:
 
 protected void RadGrid1_PreRender(object sender, EventArgs e)  
    {  
        // Here check for whether Rebind occurs or not  
        // int rowIndex = 0;   masterTableIndex  
        // int childRowIndex = 0;   Child table index  
        GridDataItem masterTableItem = (GridDataItem)RadGrid1.MasterTableView.Items[rowIndex]; // Get the mastertable item  
        masterTableItem.Expanded = true// Expand the item  
        masterTableItem.ChildItem.NestedTableViews[0].Items[childRowIndex].Selected = true;   // Selects the child table item  
    }  
[Note: you can check for whether rebind is invoked (by using any global variable, session variable etc), and execute the code to expand mastertable item and select the corresponding childitem.]


Thanks,
Princy.
0
Stuart Hemming
Top achievements
Rank 2
answered on 05 Jul 2010, 11:13 AM
Princy,

you are a, err, Prince.

It simply never occurred to me that I was trying to expand the wrong thing.

Thanks again.

-- 
Stuart - Proof that you really can be this stupid with just the one head.
Tags
Grid
Asked by
Stuart Hemming
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 1
Stuart Hemming
Top achievements
Rank 2
Share this question
or