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

Heirarchical Grid disable "Add New Record" dynamically in Child gridviews

1 Answer 26 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shaun
Top achievements
Rank 1
Shaun asked on 22 Aug 2012, 10:12 PM

When a parent record is expanded I want to evaluate and either show or hide the AddNewRecordButton on the multiple detail tables . I found that I can turn it off in the ItemDataBound event with this code.  Which appears to work until the grid  rebinds and then it applies to all records universally. I think I am coming at this from the wrong direction.  Is there a better way? 

GridDataItem item = (GridDataItem)e.Item;
if (_currentDate < DateTime.Today && _currentDate != null)
   {
 ((RadGrid)(item.Parent.Parent.Parent)).MasterTableView.DetailTables[0].CommandItemDisplay = Telerik.Web.UI.GridCommandItemDisplay.None;
 ((RadGrid)(item.Parent.Parent.Parent)).MasterTableView.DetailTables[1].CommandItemDisplay = Telerik.Web.UI.GridCommandItemDisplay.None;
 ((RadGrid)(item.Parent.Parent.Parent)).MasterTableView.DetailTables[2].CommandItemDisplay = Telerik.Web.UI.GridCommandItemDisplay.None;
}

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Aug 2012, 04:46 AM
Hi,

Try disabling the CommandItem as shown below.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
 if (e.Item is GridCommandItem && e.Item.OwnerTableView.Name == "DetailTable1")
 {
   GridCommandItem item = (GridCommandItem)e.Item;
   item.Enabled = false;
 }
}

Thanks,
Shinu.
Tags
Grid
Asked by
Shaun
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or