jquery easy ui datarid 使用 写个demo做个记录
easyui datagrid
设置:{ field: 'ck', checkbox: true, checked: false, width: 50, align: 'left' }
使用checkbox达到多选的效果 但是却只能选择一个项
原因是设置了属性:singleSelect: true 改成false就可以了。
$(function () { //初始化列表 $('#tabelJiLuDanFl').datagrid({ fit: true, width: "150px", singleSelect: true, striped: true, columns: [[ { field: 'FENLEIMC', title: '分类', width: 147, align: 'center' } ]], border: false, onSelect: function (rowIndex, rowData) { feiLeiId = rowData.FENLEIID; getXiangMu('0',""); } }); $("#ddlShiYongFw").change(function () { getXiangMu($(this).val()); }); $('#tableJiLuDanXm').datagrid({ fit: true, singleSelect: false, striped: true, idField: "XIANGMUID", columns: [[ { field: 'ck', checkbox: true, checked: false, width: 20, align: 'left' }, { field: 'XIANGMUMC', title: '项目名称', editor: { type: 'text', required: true }, width: 450, align: 'left' }, { field: 'CHUANGJIANRXM', title: '创建人', editor: { type: 'text', required: true }, width: 60, align: 'left' }, { field: 'CHUANGJIANSJ', title: '创建时间', editor: { type: 'text', required: true }, width: 100, align: 'left' }, { field: 'SHIYONGFW', title: '使用范围', width: 80, align: 'center', formatter: function (val, rec, i, rows) { if (rec.SHIYONGFW == '0') return "本人"; else if (rec.SHIYONGFW == '1') return '科室'; else if (rec.SHIYONGFW == '2') return '全院'; }, editor: { type: 'combobox', options: { panelHeight: 'auto', valueField: 'value', textField: 'text', data: shiYongFwData, required: true } } } ]], border: false, rownumbers: true, onSelect: function (rowIndex, rowData) { //var feiLeiId = rowData.FENLEIID; }, onLoadSuccess: function (data) { if ($(this).datagrid('getRows').length > 0) { $(this).datagrid('clearSelections').datagrid('selectRow', 0); } } }); 多选删除: function zuoFei() { if (!confirm("确认要删除吗?")) return; var $grid = $("#tableJiLuDanXm"); var selectRow = $grid.datagrid("getSelections"); if (selectRow.length == 0) { showmsgbox("当前未选中记录", "error"); } else { var id = ""; for (var i = 0; i < selectRow.length; i++) { id += selectRow[i].XIANGMUID + ","; } id = id.substr(0,id.length-1); var ret = Pad_Pad_XiangMuLb.ZuoFeiXm(id); if (ret.error) { showmsgbox(ret.error.Message, "error"); } else { if (ret.value > 0) { for (var i = 0; i < selectRow.length; i++) { var rowIndex = $grid.datagrid("getRowIndex", selectRow[i]); $grid.datagrid("deleteRow", rowIndex); } } else { showmsgbox("删除失败", "error"); } } } }