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

Details GridTableView ClientID blank

1 Answer 14 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mick
Top achievements
Rank 1
Mick asked on 30 Jul 2015, 08:21 AM

When I inspect the GridCommandEventArgs event args in the OnItemCommand event handler I find...

e.Item.OwnerID "ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_​myControl_gvMyGridWithTheDetailsTable_ctl00_ctl06_Detail10" string

and

e.Item.OwnerTableView.ClientID "ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_​myControl_gvMyGridWithTheDetailsTable_ctl00_ctl06_Detail10" string

However ...

((RadGrid)sender).MasterTableView.DetailTables[0].ClientID "" string (IT'S BLANK!)

and

gvMyGridWithTheDetailsTable.MasterTableView.DetailTables[0].ClientID "" string (IT'S ALSO BLANK!)


gvMyGridWithTheDetailsTable == sender true bool  

and

gvMyGridWithTheDetailsTable.MasterTableView.DetailTables[0] == ((RadGrid)sender).MasterTableView.DetailTables[0] true bool

as you'd expect, but..

e.Item.OwnerTableView == ((RadGrid)sender).MasterTableView.DetailTables[0]    ***false***   bool   

and yes there's only one details table....

((RadGrid)sender).MasterTableView.DetailTables.Count 1  int

What's going on here?  
Why aren't the instances of the GridTableView in the GridCommandEventArgs and the GridTableView of the sending datagrid the same?
Why don't they have the same property values?

I'm attempting customise viewstate for my datagrid, by disabling viewstate on the grid and saving the state I want kept manually.  I was hoping to write generic code for this that would work with RadGrids ​which have DetailTables. In the case of the Detail tables, not being able to correlate the ID of the grid being sorted in the OnItemCommand with the ID of anything in the Pre_Load event of the page is going to stop me from being able to restore the state for the grid.

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 04 Aug 2015, 06:52 AM
Hello Mick,

In order to correctly access the detail table you should do so by accessing the expanded items NestedTableViews collection.

C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    GridDataItem item = e.Item as GridDataItem;
    if (item != null && item.ChildItem.NestedTableViews.Length > 0)
    {
        string id = item.ChildItem.NestedTableViews[0].ID;
    }
}

If the above approach does not prove helpful please share with us the entire page contents so we could examine the implementation and determine why are you observing such behavior.

Regards,
Angel Petrov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Mick
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or