$ (' #dg '). DataGrid ({title:' CheckBox Selection on DataGrid ', URL:' Datagrid_data3.json ', Width:' 700 ', Rownumbers:true, columns:[[{field:' CK ', checkbox:true}, {field:' ProductID ', title: ' ProductID '}, {field:' ProductName ', title: ' ProductName '}, {field:' UnitCost ', title: ' UnitCost '}, {field:' Status ', title: ' Status '}, {field:' ListPrice ', title: ' ListPrice '}, {field:' Itemid ', title: ' Itemid '}]], Singleselect:false, Selectoncheck:true, Checkonselect:true, onloadsuccess:function(data) {if(data) {$.each (data.rows,function(Index, item) {if(item.checked) {$ (' #dg '). DataGrid (' Checkrow ', index); } }); } } }); $(' #ButonGetCheck '). Click (function(){ varCheckedItems = $ (' #dg '). DataGrid (' getchecked '); varNames = []; $.each (CheckedItems,function(Index, item) {Names.push (item.productname); }); Console.log (Names.join (","));});
$(function(){ $(' #dg '). DataGrid ({title:' CheckBox Selection on DataGrid ', URL:' Datagrid_data3.json ', Width:' 700 ', Rownumbers:true, columns:[[{field:' Checked ', formatter:function(value,row,index) {if(row.checked) {return' <input type= ' checkbox ' name= ' datagridcheckbox ' checked= ' checked ' > '; } Else{ return' <input type= ' checkbox ' name= ' Datagridcheckbox > '; }}}, {field:' ProductID ', title: ' ProductID '}, {field:' ProductName ', title: ' ProductName '}, {field:' UnitCost ', title: ' UnitCost '}, {field:' Status ', title: ' Status '}, {field:' ListPrice ', title: ' ListPrice '}, {field:' Itemid ', title: ' Itemid '}]], Singleselect:true }); $(' #ButonGetCheck '). Click (function(){ varCheckedItems = $ (' #dg '). DataGrid (' getchecked '); varNames = []; $.each (CheckedItems,function(Index, item) {Names.push (item.productname); }); Console.log (Names.join (",")); });}); $.extend ($.fn.datagrid.methods, {getchecked:function(JQ) {varRR = []; varrows = Jq.datagrid (' getRows '); Jq.datagrid (' Getpanel '). Find (' Div.datagrid-cell input:checked '). each (function () { varIndex = $ ( This). Parents (' Tr:first '). attr (' Datagrid-row-index ')); Rr.push (Rows[index]); }); returnRR; }});
JQuery Easyui DataGrid Checkbox data Set and value