Hi,
I tried this in the DetailTableDataBind event handler
the column is successfully added, but as soon as a postback occurs, the new column disappears. But adding a column the exact same way to the MasterTableView works as intended.
I have also tried this:
Doing this works if I need to programmatically add columns to the first level of the hierarchy (you loop over each item in the MasterTableView and check whether or not each item is expanded or not), but how could you add columns to a detail grid at any level of the hierarchy?
I am having the same issue as an unanswered question in the second half of this thread (by Bruno):
http://www.telerik.com/community/forums/aspnet-ajax/grid/dynamically-add-columns-to-existing-radgrid.aspx
Thanks,
Donald
I tried this in the DetailTableDataBind event handler
GridBoundColumn b = new GridBoundColumn();e.DetailTableView.Columns.Add(b);b.HeaderText = "test";the column is successfully added, but as soon as a postback occurs, the new column disappears. But adding a column the exact same way to the MasterTableView works as intended.
I have also tried this:
protected void RadGrid1_PreRender(object sender, EventArgs e){ foreach (GridDataItem item in RadGrid1.MasterTableView.Items) { if (item.Expanded) { dynamic data = new[] { new { ID = "1", Name ="Name11",ParentID = "0"}, new { ID = "2", Name ="Name11",ParentID = "1"}, new { ID = "3", Name ="Name11",ParentID = "2"}, new { ID = "4", Name ="Name11",ParentID = "3"} }; GridBoundColumn b = new GridBoundColumn(); b.HeaderText = "test"; b.DataField = "Name"; item.ChildItem.NestedTableViews[0].Columns.Add(b); item.ChildItem.NestedTableViews[0].DataSource = data; item.ChildItem.NestedTableViews[0].DataBind(); } }}Doing this works if I need to programmatically add columns to the first level of the hierarchy (you loop over each item in the MasterTableView and check whether or not each item is expanded or not), but how could you add columns to a detail grid at any level of the hierarchy?
I am having the same issue as an unanswered question in the second half of this thread (by Bruno):
http://www.telerik.com/community/forums/aspnet-ajax/grid/dynamically-add-columns-to-existing-radgrid.aspx
Thanks,
Donald