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

detailtable wih check all input

2 Answers 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Loyal User
Top achievements
Rank 1
Loyal User asked on 22 May 2014, 03:04 PM
i have a radgrid with detailtable that contains columns with checkbox,
main grid contains only one column for grouping.
i use DetailTableDataBind to bind nestedgrid,

what i want is to put a global checkbox inside main grid to check all boxes inside all detail tables at once , for each column inside nestedtable 

how to achieve that ?



2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 May 2014, 10:34 AM
Hi,
I guess you have a Template column with checkbox in the main Grid and again checkbox in your detail table. On checking main grid checkbox you want to check checkboxes inside detail table. Please try the following code snippet.

ASPX:
<MasterTableView
    <DetailTables>
        <telerik:GridTableView>         
            <Columns>
                <telerik:GridTemplateColumn>
                    <ItemTemplate>
                        <asp:CheckBox ID="CheckBoxChild" runat="server" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>             
            </Columns>
        </telerik:GridTableView>
    </DetailTables>
    <Columns>
        <telerik:GridTemplateColumn>
            <ItemTemplate>
                <asp:CheckBox ID="CheckBoxMaster" runat="server" AutoPostBack="true" OnCheckedChanged="CheckBoxMaster_CheckedChanged" />
            </ItemTemplate>
        </telerik:GridTemplateColumn>      
    </Columns>
</MasterTableView>

C#:
protected void CheckBoxMaster_CheckedChanged(object sender, EventArgs e)
{
  CheckBox CheckBox = (sender as CheckBox);
  GridDataItem parentItem = (GridDataItem)CheckBox.NamingContainer; 
  GridTableView detailTable = (GridTableView)parentItem.ChildItem.NestedTableViews[0];
  foreach (GridDataItem dataItem in detailTable.Items)// loops through DetailTable item
  {
   (dataItem.FindControl("CheckBoxChild") as CheckBox).Checked = true;// accessing checkbox in DetailTable       
  }
}

Thanks,
Shinu
0
Radoslav
Telerik team
answered on 27 May 2014, 11:05 AM
Hello,

I am sending you a simple example which demonstrates one of the possible approaches for achieving the desired functionality. Please check it out and let me know if it helps you.

Looking forward for your reply.

Regards,
Radoslav
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
Loyal User
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Radoslav
Telerik team
Share this question
or