这是官方文档的写法,但是按照这种写法并不能得到回显结果。
下面是本人代码:
let ids =${toJson(ids)};
// 初始化DataGrid对象
dataGrid = $('#dataGrid').dataGrid({
searchForm: $("#searchForm"),
columnModel: [
{header:'${text("题干")}', name:'name', index:'a.name', width:222, align:"left"},
],
showCheckbox: true, // 显示复选框
// 加载成功后执行事件
ajaxSuccess: function(data){
$.each(ids, function(key, value){
dataGrid.dataGrid('setSelectRow', ids[key]);
});
}
});
效果:
获取选中ids:
let ids=$("#dataGrid").dataGrid('getSelectRows').join(',');