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

how to get checkbox column value in unbound mode

3 Answers 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Igor Ashmetkov
Top achievements
Rank 1
Igor Ashmetkov asked on 28 Jun 2013, 11:51 AM
        Hello!
I have RadGrid which is bound to DataSource, and one of my column (GridCheckBoColumn) is unbound.
I want to to get column value on client side:

<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" PageSize="40"  CellSpacing="0" DataSourceID="entityDsAutoJoinLog" GridLines="None" Height="100%"  OnItemDataBound="RadGrid1_ItemDataBound"
         AllowAutomaticUpdates="true" >
<ClientSettings EnableRowHoverStyle="true" >
    <Scrolling AllowScroll="true" UseStaticHeaders="true" />
</ClientSettings>
          
<MasterTableView AutoGenerateColumns="False" DataKeyNames="CLIENT_CLASS, KEY_VALUE" DataSourceID="entityDsAutoJoinLog" >
    <Columns>  
 <telerik:GridCheckBoxColumn UniqueName="Parent"  />
...


protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                CheckBox chkBoxParent = (CheckBox)dataBoundItem["Parent"].Controls[0];
                chkBoxParent.Enabled = true;
                int index = dataBoundItem.ItemIndex;
                chkBoxParent.Attributes.Add("onclick", "check('" + index + "')");
 
            }
        }

function check(index) {
    var grid = $find("<%= RadGrid1.ClientID %>");
                var MasterTable = grid.get_masterTableView();
                var row = MasterTable.get_dataItems()[index];
                var cell = MasterTable.getCellByColumnUniqueName(row, "Parent");
                if (cell.innerHTML == "True") {
                    alert('TRUE');
                }
            }



But cell.innerHTML return something like this:

<INPUT id=ctl00_ContentPlaceHolder1_RadGrid1_ctl00_ctl08_ctl00 onclick="check('2');" type=checkbox name=ctl00$ContentPlaceHolder1$RadGrid1$ctl00$ctl08$ctl00>

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 28 Jun 2013, 12:28 PM
Hello,

function check(index) {
                var grid = $find("<%= RadGrid1.ClientID %>");
                var MasterTable = grid.get_masterTableView();
                var row = MasterTable.get_dataItems()[index];
                var cell = MasterTable.getCellByColumnUniqueName(row, "Parent");
                if ($(cell).find('input').is(":checked") == true) {
                    alert('TRUE');
                }
            }

OR

if (cell.getElementsByTagName('input')[0].checked == true) {


Thanks,
Jayesh Goyani
0
Peter
Top achievements
Rank 1
answered on 22 Oct 2014, 05:30 AM
How do I access an unbound checkbox value in the Grid's UpdateCommand event? 

When I use the "ExtractValuesFromItem" method, the item has a blank name in hashtable. 
0
Peter
Top achievements
Rank 1
answered on 22 Oct 2014, 05:38 AM
I worked it out:

protected void rgGrid_UpdateCommand(object sender, GridCommandEventArgs e)
        {
            GridEditableItem editItem = e.Item as GridEditableItem;
            _isIgnore = ((CheckBox)((GridEditableItem)e.Item)["chkIgnore"].Controls[0]).Checked;
Tags
Grid
Asked by
Igor Ashmetkov
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Peter
Top achievements
Rank 1
Share this question
or