Show single detail table based on command

2 posts, 0 answers
  1. Dana
    Dana avatar
    1 posts
    Member since:
    Aug 2015

    Posted 14 Aug 2015 Link to this post

    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.

  2. Kostadin
    Kostadin avatar
    1733 posts

    Posted 19 Aug 2015 Link to this post

    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.

    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