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

Show single detail table based on command

1 Answer 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dana
Top achievements
Rank 1
Dana asked on 14 Aug 2015, 01:41 PM

I have a master view with two child views.  I would like to have command buttons on the master row which cause an expand to happen to one or the other child tables.  When I handle the ItemCommand event, I hide set all detail tables to Visible=False but they are still visible on the output.

I've tried setting the expanded and visibility of the detail tables right within the ItemCommand event like this:

 

if (e.CommandName == "ExpandSomething")
{
    item.Expanded = true;
    foreach (var table in MyGrid.MasterTableView.DetailTables)
        if (table.Name != "Something")
            table.Visible = false;
}
 

Then I thought maybe the hiding needed to be done later in the event cycle so I tried it like this: 

 

private string _activeChildView = null;
protected void ShowSingleChildTable(string name) //this is called from item command
{
    _activeChildView = name;
}
 
private void Page_PreRender(object sender, EventArgs e)
{
    if (_activeChildView != null)
        foreach (var table in AdminGrid.MasterTableView.DetailTables)
            if (table.Name != _activeChildView)
                table.Visible = false;
}

Neither way works - both grids are always visible.

In playing around with different events, I've found that the DataBinding event is the only place that setting the visibility to false works, but unfortunately that fires before the ItemCommand so I can't figure out if a detail button was pressed.

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 19 Aug 2015, 08:11 AM
Hi Dana,

You can still hide the child detail tables on PreRender event handler but you need to call Rebind of the grid after that. This way the changes will take effect after the postback.

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