datagrid colume define:
{
title:'<strong>姓名</strong>',
field:'EmpID',
rowspan:2,
width:68,
align:'center',
formatter:function(value,row){
return row.EmpName;
},
editor:{
type:'combobox',
options:{
valueField:'EmpID',
textField:'EmpName',
url:'emp.json',
multiple:false,
editable:false,
required:false
}
}
}
datagrid onClickRow handle:
onClickRow:function(rowIndex){
if (lastIndex != rowIndex && $(this).datagrid('validateRow', lastIndex)){
var ed = $(this).datagrid('getEditor', {index:lastIndex, field:'EmpID'});
if (ed){
$(this).datagrid('getRows')[lastIndex]['EmpName'] = $(ed.target).combobox('getText');
}
$(this).datagrid('endEdit', lastIndex);
$(this).datagrid('beginEdit', rowIndex);
lastIndex = rowIndex;
} else {
$(this).datagrid('selectRow', lastIndex);
}
}
emp.json:
[
{"EmpID":289,"EmpName":"\u66f9\u6587\u771f"},
{"EmpID":290,"EmpName":"\u675c\u6c38\u5f3a"},
{"EmpID":291,"EmpName":"\u51af\u7acb\u660e"},
{"EmpID":292,"EmpName":"\u4ed8\u6653\u94a2"},
{"EmpID":293,"EmpName":"\u90ed\u8fde\u745e"},
{"EmpID":295,"EmpName":"\u674e\u5b9d\u5149"},
{"EmpID":296,"EmpName":"\u674e\u798f\u589e"},
{"EmpID":294,"EmpName":"\u674e\u5efa"},
{"EmpID":297,"EmpName":"\u674e\u6770\u5112"},
{"EmpID":298,"EmpName":"\u674e\u4fca\u51ef"},
{"EmpID":299,"EmpName":"\u674e\u5e0c\u81e3"},
{"EmpID":301,"EmpName":"\u5218\u7115\u5947"},
{"EmpID":300,"EmpName":"\u5218\u8f89"},
{"EmpID":302,"EmpName":"\u8def\u5bb6\u8fdb"},
{"EmpID":303,"EmpName":"\u9a6c\u5b50\u6d9b"},
{"EmpID":304,"EmpName":"\u6bdb\u6811\u5cad"},
{"EmpID":305,"EmpName":"\u7c73\u6842\u6885"},
{"EmpID":306,"EmpName":"\u725b\u6811\u6a80"},
{"EmpID":307,"EmpName":"\u6f58\u745e\u5b58"},
{"EmpID":308,"EmpName":"\u4efb\u56fd\u653f"},
{"EmpID":309,"EmpName":"\u82ae\u5efa\u8f89"},
{"EmpID":310,"EmpName":"\u738b\u5efa\u5fe0"},
{"EmpID":311,"EmpName":"\u738b\u514b\u65b0"},
{"EmpID":312,"EmpName":"\u738b\u7acb\u5cf0"}
]