好用的jqgrid最新版是5.0以后的,但是收费的。所以能用的最新版本也就是4.4.3版本的。
使用checkbox列是比较尴尬,不能自定义标题么?
$("#gridColumnList").jqGrid({
datatype: 'local',
height:"auto",
autowidth: true,
colModel: [
{ label: '列名', name: 'colName', hidden:true },
{ label: '默认序号', name: 'ord', hidden: true},
{
label: '是否显示', name: 'vis', width: 40, align: "center",
formatter: function (cellvalue, options, rowObject) {
var control = "";
if (cellvalue == "true") {
control = "<input name='input_vis' type='checkbox' data-colName='" + rowObject.colName + "' data-ord='" + rowObject.ord + "' data-label='" + rowObject.label + "' checked value='" + rowObject.colName + "' οnclick='setCKStatus();'/>";
}
else {
control = "<input name='input_vis' type='checkbox' data-colName='"+rowObject.colName + "' data-ord='" + rowObject.ord + "' data-label='" + rowObject.label + "' οnclick='setCKStatus();'/>"
}
return control;
}
},
{ label: '标题', name: 'label', width: 120 }
],
viewrecords: true,
gridview: true,
//multiselect: true,//复选框
gridComplete: function () {
//var rowIds = $("#gridColumnList").jqGrid('getDataIDs');
//for (var k = 0; k < rowIds.length; k++) {
//var curRowData = $("#gridColumnList").jqGrid('getRowData', rowIds[k]);
//var curChk = $("#" + rowIds[k] + "").find(":checkbox");
//curChk.attr('name', 'gridConfigCheckBoxItem'); //给每一个checkbox赋名字
//curChk.attr('value', curRowData['MY_ID']); //给checkbox赋值
//curChk.attr('title', curRowData['NAME']); //给checkbox赋予额外的属性值
//curChk.attr('checked', 'true'); //设置所有checkbox被选中
//}
}
});
但是如果不想用checkbox列,想自定义一个新使用checkbox控件,不使用multiselect属性的话,只能自定义列的