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

Conditional Hiding of RadGrid DetailTables

1 Answer 268 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kelly
Top achievements
Rank 1
Kelly asked on 23 May 2014, 07:07 AM
Hi Team.
We have a scenario where we want to conditionaly hide the detail tables. Below is our structure and we need to hide the childHeader and childRow. 
.aspx
<telerik:RadGrid>
 <MasterTableView >
    <DetailTables>
      <telerik:GridTableView name="Parent">
      </telerik:GridTableView >
    </DetailTables>
<DetailTables>
      <telerik:GridTableView  name="ChildHeader">
         <DetailTables>
            <telerik:GridTableView  name="ChildRow">
           </telerik:GridTableView >
        </DetailTables>
    <telerik:GridTableView >
</DetailTables>
</MasterTableView>
</telerik:RadGrid>


.cs

 protected void radgrid_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
    {
        GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
        switch (e.DetailTableView.Name)
        {
            case "ParentRow":
                {
                    //code for parentrow detail table here
                }
            case "ChildHeader":
                {
                   //code for ChildHeader detail table here
                    break;
                }
            case "ChildRow":
                {
                    //code for ChildRow detail table here
                    break;
                }
        }
Now, DetailTableDataBind method iterates on each detailTable, Is it possible to remove the detailtable so that it does not even render and code in DetailTableDataBind method for childHeader and childRow does not execute. Right now its erroring when it goes in these case statements.
So the requirement is to hide these detail tables conditionally and not execute the code for child header and chidRow in above case statement

1 Answer, 1 is accepted

Sort by
0
Accepted
Kostadin
Telerik team
answered on 27 May 2014, 11:27 AM
Hello Kelly,

Basically you could not prevent calling DetailTableDataBind event for all detail tables. Nevertheless you could set an empty string as a DataSource of the appropriate detail table on DetailTableDataBind.
e.DetailTableView.DataSource = string.Empty;
Another approach is to get the detail tables and set its Visible property to false. This way the table will not be rendered on the browser.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Kelly
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or