var datas = {total:6,rows:[ {id:1,content:'内容1'}, {id:2,content:'内容2'}, {id:3,content:'内容3'}, {id:4,content:'内容4'}, {id:5,content:'内容5'}, {id:6,content:'内容6'} ]}; <!-------------------处理结果表格--------------------------> var editcount = 0; $('#process').datagrid({ title:'处理结果选项设置', width:600, height:'auto', singleSelect:true, columns:[[ {field:'no',title:'编号',width:100, formatter:function(value, rowData, index){ return index+1; } }, {field:'content',title:'名称',width:394,editor:'text'}, {field:'id',title:'操作',width:100,align:'id', formatter:function(value,row,index){ if (row.editing){ var s = '<a href="#" onclick="saverow('+index+')">保存</a> '; var c = '<a href="#" onclick="cancelrow('+index+')">取消</a>'; return s+c; } else { var e = '<a href="#" onclick="editrow('+index+')">编辑</a> '; var d = '<a href="#" onclick="deleterow('+index+')">删除</a>'; return e+d; } } } ]], onBeforeEdit:function(index,row){ row.editing = true; $('#process').datagrid('refreshRow', index); editcount++; }, onAfterEdit:function(index,row){ row.editing = false; $('#process').datagrid('refreshRow', index); editcount--; }, onCancelEdit:function(index,row){ row.editing = false; $('#process').datagrid('refreshRow', index); editcount--; } }).datagrid('loadData',datas).datagrid('acceptChanges'); }); function editrow(index){ $('#process').datagrid('beginEdit', index); }