2016年7月3日 星期日

Remove RadGrid DetailTables AutoGeneratedColums

Refer:

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();
        }
    } 
}

 

沒有留言: