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

3 posts, 0 answers
  1. Randall
    Randall avatar
    54 posts
    Member since:
    Jun 2008

    Posted 07 Sep 2011 Link to this post

    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. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 08 Sep 2011 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Randall
    Randall avatar
    54 posts
    Member since:
    Jun 2008

    Posted 12 Sep 2011 Link to this post

    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
Back to Top