Refer:
- http://www.telerik.com/forums/set-datasource-of-details-view-in-code-behind
- http://stackoverflow.com/questions/13605169/how-to-delete-autogenerated-columns-from-telerik-radgrid
Problem: I can’t take the result by using RadGrid’s ItemCommand() that autogenerated fixed columns once created. So I can’t get dynamic detail tables.
Solution: Should use RadGrid’s PreRender() . This is an important concept here.
protected void MainList_PreRender(object sender, EventArgs e)
{
RadGrid thisGrid = sender as RadGrid;
thisGrid.MasterTableView.DetailTables.Clear();
thisGrid.MasterTableView.DetailTables.Add(new GridTableView());
foreach (GridDataItem item in MainList.MasterTableView.Items)
{
if (item.Expanded)
{
GridTableView nestedView = (GridTableView)item.ChildItem.NestedTableViews[0];
nestedView.DataSource = your_dataSource;
nestedView.DataBind();
}
}
}
沒有留言:
張貼留言