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

Hiding the 'Add New' button in DetailTables

1 Answer 96 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 30 Nov 2011, 01:50 PM
Depending on a value in the expanded parent row, I want to display/hide the 'Add New' button in the DetailTable.  For instance, if 'Test A' in the MasterTableView is inactive, I don't want the 'Add New' button to appear if 'Test A' is expanded to show the DetailTable.  Any help would be appreciated.

1 Answer, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 02 Dec 2011, 04:41 PM
Hi Martin,

You could hide the Add New Record button for a specific DetailTable by calling the code below:

this.RadGrid1.MasterTableView.DetailTables[detailTableIndex].CommandItemSettings.ShowAddNewRecordButton = false
Additionally, to check if a item in the RadGrid is expended you you could take a look at the code below:
foreach (GridDataItem item in this.RadGrid1.Items)
{
    if (item.Expanded)
    {
        //your code logic here
    }
}
I have created a little code demo to show a possible scenario that should be close to what you are requesting.
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.ExpandCollapseCommandName)
    {
        if (e.Item.Expanded)
        {
            e.Item.OwnerTableView.CommandItemSettings.ShowAddNewRecordButton = false;
        }
    }
         
}

All the best,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Martin
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Share this question
or