<table class="easyui-datagrid" title="人员选择" id="dg"
data-options="singleSelect:false,toolbar:'#toolbar',pagination:false,fit:true,
onSelect:function(rowIndex,rowData){
var iflag=0;
if(selceids.length<1){
selceids.push(rowData.TrueName);
}else{
for (var i=0 ; i < selceids.length ; i++){
if(rowData.TrueName===selceids[i]){
iflag=1;
break;
}
}
if(iflag===0){
selceids.push(rowData.TrueName);
}
}
},
onSelectAll:function(rows){
var iflag=0;
for(var j=0;j<rows.length;j++){
if(selceids.length<1){
selceids.push(rows[j].TrueName);
}else{
for (var i=0 ; i < selceids.length ; i++){
if(rows[j].TrueName===selceids[i]){
iflag=1;
break;
}
}
if(iflag===0){
selceids.push(rows[j].TrueName);
}
}}
},
onUnselect:function(rowIndex,rowData){
for (var i=0 ; i < selceids.length ; i++ ){
if(rowData.TrueName===selceids[i]){
selceids.splice(i,1);
break;
}
}
},
onUnselectAll:function(rows){
for(var j=0;j<rows.length;j++){
for (var i=0 ; i < selceids.length ; i++ ){
if(rows[i].TrueName===selceids[i]){
selceids.splice(i,1);
break;
}
}
}
},onLoadSuccess:function(row){//当表格成功加载时执行
var rowData = row.rows;
$.each(rowData,function(idx,val){//遍历JSON
for (var i=0 ; i < selceids.length ; i++ ){ if(val.TrueName===selceids[i]){
$('#dg').datagrid('selectRow', idx);
}
} });
}">
<thead>
<tr>
<th data-options="field:'ID',checkbox:true">ID</th>
<th data-options="field:'TrueName',width:80">真实名</th>
</tr>
</thead>
</table>
记性差,做个标记。