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

Find All check box controls in a row

2 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rhbkv
Top achievements
Rank 1
Rhbkv asked on 07 Aug 2012, 04:38 PM
Hi,

I am using Telerik rad grid version 2010.1.519 in VS 2010 project. I am loading the rad grid columns dynamically.
And first column in the datagrid is "GridClientSelectColumn". When I check first column in check box, I need to find out all other check boxes available in the selected row in javascript to make it checked as same as attached screenshot
Could you pleas help me to get the solution.
Thanks

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Aug 2012, 06:54 AM
Hi,

Here is a sample code snippet to check all the CheckBoxes(inside ItemTemplate of GridTemplateColumn) in a row when GridClientSelectColumn is checked.

C#:
Radgrid1.AllowMultiRowSelection = true;
Radgrid1.ClientSettings.Selecting.AllowRowSelect = true;
Radgrid1.ClientSettings.ClientEvents.OnRowSelected = "OnRowSelected";
Radgrid1.ClientSettings.ClientEvents.OnRowDeselected = "OnRowDeselected";

Javascript:
function OnRowSelected(sender, args)
{
    var grid = sender;
    var MasterTable = grid.get_masterTableView();
    var selectedRows = MasterTable.get_selectedItems();
    for (var i = 0; i < selectedRows.length; i++)
    {
            var row = selectedRows[i];
            row.findElement("CheckBox1").checked = true;
            row.findElement("CheckBox2").checked = true;
            row.findElement("CheckBox3").checked = true;
    }
}
function OnRowDeselected(sender, args)
{
    var grid = sender;
    var MasterTable = grid.get_masterTableView();
    var rows = MasterTable.get_dataItems()[args.get_itemIndexHierarchical()]  
    rows.findElement("CheckBox1").checked = false;
    rows.findElement("CheckBox2").checked = false;
    rows.findElement("CheckBox3").checked = false;   
}

Thanks,
Princy.
0
Rhbkv
Top achievements
Rank 1
answered on 08 Aug 2012, 01:27 PM
Thanks Princy.

I have to create columns in the grid dynamically depends on the database values. So the number of checkboxes in a row will be vary. So I haven't created check boxes with ID at design time. I am able find all check boxes from server side as "foreach (Control C in GridDataItem.Controls)"  on ItemDataBound method. Is there any way we can do in the Javascript?
Thanks.
Tags
Grid
Asked by
Rhbkv
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Rhbkv
Top achievements
Rank 1
Share this question
or