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

How do I get the value of the CheckBox in GridClientSelectColumn for the selected row using Javascript

2 Answers 412 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Randall
Top achievements
Rank 2
Randall asked on 07 Sep 2011, 08:57 PM
Hello,

Using RadControls for ASP.NET v2011.2.712.35

How do I get the checked value using Javascript for a GridClientSelectColumn in a RadGrid when I click a row in a RadGrid?

Thanks,

Randall Price
Senior Developer
Virginia Tech

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Sep 2011, 06:03 AM
Hello Randall,

Try the following aspx and Javascript to retrieve the value of Checkbox in GridClientSelectColumn.
aspx:
<telerik:RadGrid ID="RadGrid1" runat="server">
   <ClientSettings>
      <ClientEvents OnRowSelected="RowSelected" />
   </ClientSettings>
</telerik:RadGrid>
JS:
function RowSelected(sender, eventArgs)
  {
    var grid = sender;
    var MasterTable = grid.get_masterTableView();
    var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
    var cell = MasterTable.getCellByColumnUniqueName(row, "ColUniqueName");
    alert(cell.innerHTML);
  }

Thanks,
Shinu.
0
Randall
Top achievements
Rank 2
answered on 12 Sep 2011, 03:35 PM
Hello Shinu,

Thanks for your response to this issue.  The code you provided gets me to the <TD> tag that holds the CheckBox.  I used the following code to get to the actual Checkbox in the <TD>:

function OP_RadGrid_RowClick(sender, args)
{
    var oMasterTable = m_oRadGrid.get_masterTableView();
    var oRow  = oMasterTable.get_dataItems()[args.get_itemIndexHierarchical()];
    var oCell = oMasterTable.getCellByColumnUniqueName(oRow, "CheckboxSelectColumn");
    var oCheckBox = oCell.firstChild;
    alert("oCell.nodeName: "     + oCell.nodeName     + "\r\n" +
        "oCheckBox.nodeName: " + oCheckBox.nodeName + "\r\n" +
        "oCheckBox.type: "     + oCheckBox.type);
}

As you can see, oCell is the <TD> tag and oCheckBox is the <INPUT type=CheckBox...> tag.

Thanks,

Randall Price
Senior Developer
Virginia Tech
Tags
Grid
Asked by
Randall
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Randall
Top achievements
Rank 2
Share this question
or