Details GridTableView ClientID blank

2 posts, 0 answers
  1. Mick
    Mick avatar
    16 posts
    Member since:
    May 2012

    Posted 30 Jul 2015 Link to this post

    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.

  2. Angel Petrov
    Admin
    Angel Petrov avatar
    1086 posts

    Posted 04 Aug 2015 Link to this post

    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
Back to Top