开发者

Setting GridCheckBoxColumn in Telerik RadGrid from the client side

I have a GridCheckBoxColumn inside a Telerik RadGrid. I want to loop through all the rows on the client side and set the value of each checkbox. I can't figure out how to get the checkbox control. So far I have:

            var grid = $find("<%=RadGrid1.ClientID %>");
            var masterTableView = grid.get_masterTableView();
            if (masterTableView != null) {
                var gridItems = masterTableView.get_dataItems();
                var i;
                for (i = 0; i < gridItems.length; ++i) {
                    var gridItem = gridItems[i];
                    // How do I get the checkbox here? Note - since it's a CheckBox开发者_StackOverflow社区 column, 
                    // I don't know the id of the checkbox.

                    // This doesn't work:
                    var control = gridItem.Controls[0];
                    control.checked = false;  
                }
            }


I figured it out. Here's how I did it:

 var grid = $find("<%=RadGrid1.ClientID %>");
 var masterTableView = grid.get_masterTableView();
 if (masterTableView != null) {
     var gridItems = masterTableView.get_dataItems();
     var i;
     for (i = 0; i < gridItems.length; ++i) {
         var gridItem = gridItems[i];
         var cell = gridItem.get_cell("chkSelect");
         var controlsArray = cell.getElementsByTagName('input');
         if (controlsArray.length > 0) {
             var rdo = controlsArray[0];
             rdo.checked = header_checkbox.checked;
         }
     }
 }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜