Wednesday, June 26, 2013

Kendo Grid Select All Check Box

Select All check Box Functionality for Kendo UI Grid

function SelectAll() 
{
if ($("#chkSelectAll").attr('checked')) { $(".k-grid-content tbody tr").each(function () {

var values = [];
var $row = $(this);
//where .inpchk is the class name
var checked = $row.find('.inpchk').attr('checked');
if (($row.find(".inpchk").attr('disabled') == 'disabled')) {
$row.find(".inpchk").removeAttr('checked');
}
else {
   
$row.find(".inpchk").attr('checked', 'checked');
}
            

               

});

}


else {                   
 $(".k-grid-content tbody tr").each(function () {

var $row = $(this);
$row.find(".inpchk").removeAttr('checked');                   

});

}
             
}

------------------------------------

//Grid Binding

 $("#grdid").kendoGrid({

dataSource: {

data: obj,

schema: {

model: {

fields: {

Severity: { type:
"string" },

AlertMsgId: { type: "number" },

Active: { type: "string" }

}

}

},

pageSize: 5

},

serverPaging:
true,

serverFiltering: true,

serverSorting: true,

height: 200,

filterable:
true,

sortable: true,

pageable: true,

selectable: true,

dataBound: onDataBound,

columns: [

{

field:
"check_row", title: " ", filterable: false, sortable: false,

template: "<input class='inpchk' type='checkbox'/>",

title: "<input type='checkbox' id='chkSelectAll' onchange='SelectAll();'/>",

width: 34

},

{

hidden:
true,

title: "Id",

field: "Id",

width: 50

},

{

title:
"Severity",

field: "Severity",

width: 80

}

 ]

});

});
                                        



       


                   


                       



                   


                       

                   


           

           


               

                   

                   

           

 

2 comments: