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

Template Checkbox Retrieve Key Value

1 Answer 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff Grol
Top achievements
Rank 1
Jeff Grol asked on 06 Apr 2010, 07:05 PM
I have a template checkbox column in a RadGrid.   I can't figure out how to access the ClientDataKeyNames column value for the rows in which the checkboxes are "checked" using javascript.  Any help would be greatly appreciated.


1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Apr 2010, 08:00 AM
Hello Jeff,

Here is the client side code that I tried for similar scenario. I hope this would help you.

JavaScript:
 
<script type="text/javascript"
 function getCheckedKeys() { 
        var grid = $find("<%= RadGrid1.ClientID %>"); 
        var masterTableview = grid.get_masterTableView(); 
        var dataitems = masterTableview.get_dataItems(); 
        var i = 0; 
        for (i = 0; i < dataitems.length; i++) { 
            var checkbox = dataitems[i].findElement("chkTest"); 
            if (checkbox.checked) { 
                alert(dataitems[i].getDataKeyValue('ContactName')); 
            } 
        } 
    }        
</script>  

And the aspx is:
 
   . . . 
<telerik:GridTemplateColumn> 
    <ItemTemplate> 
        <asp:CheckBox ID="chkTest" runat="server" /> 
    </ItemTemplate> 
</telerik:GridTemplateColumn> 
   . . . 

Thanks,
Princy.
Tags
Grid
Asked by
Jeff Grol
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or