easyui datagrid 行编辑和提交方,废话就不多说了,直接上代码

 <div style="margin: 5px;">
<table id="dg" class="easyui-datagrid" title="确认单据" style="width: 100%; height: 540px; margin: 20px;"
data-options="loadMsg: '正在加载,请稍候...',
nowrap: false,
border: true,
methord: 'post',
collapsible: false,
fit: false,
fitColumns: false,
remoteSort: true,
rownumbers: true,
pagination: true,
pageSize: 20,
pageList: [20, 30, 40, 50, 100],
striped: true,
toolbar: '#tb',
onClickRow: onClickRow,
singleSelect:false">
<thead>
<tr> <th data-options="field:'obj2',width:140,align:'center',checkbox:true">物料代码</th>
<th data-options="field:'obj1',width:75,display:'none',align:'center'">主键ID</th>
<th data-options="field:'DJID',width:70,align:'center'">单据ID</th>
<th data-options="field:'obj3',width:240,align:'center'">物料描述</th>
<th data-options="field:'obj4',width:75,align:'center'">计划数量</th>
<th data-options="field:'obj5',width:75,align:'center'">计划重量</th>
<th data-options="field:'obj6',width:80,align:'center'">实际入库数量</th>
<th data-options="field:'obj7',width:80,align:'center'">实际入库重量</th>
<th data-options="field:'obj8',width:80,align:'center',editor:'text'">入高架库数量</th>
<th data-options="field:'obj9',width:80,align:'center',editor:{type:'text'}">入高架库重量</th>
<th data-options="field:'obj10',width:80,align:'center',editor:{type:'text'}">入线边库数量</th>
<th data-options="field:'WorkName',width:80,align:'center',editor:{type:'text'}">入线边库重量</th>
</tr>
</thead>
</table>
<div id="tb" style="height: auto">
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="accept()">保存</a>
</div> </div>
界面:
easyui datagrid 批量编辑和提交数据-LMLPHP 注意:
Table的 data-options 属性 onClickRow: onClickRow 属性双击行改变行状态,用于编辑数据
 
<th data-options="field:'WorkName',width:80,align:'center',editor:{type:'text'}">入线边库重量</th>
其中的
editor:{type:'text'} 属性可以在双击后启用单元格的状态
  var editIndex = undefined;
function endEditing(){
if (editIndex == undefined){return true}
if ($('#dg').datagrid('validateRow', editIndex)){
$('#dg').datagrid('endEdit', editIndex);
editIndex = undefined;
return true;
} else {
return false;
}
}
function onClickRow(index){
if (editIndex != index){
if (endEditing()){
$('#dg').datagrid('selectRow', index)
.datagrid('beginEdit', index);
editIndex = index;
} else {
$('#dg').datagrid('selectRow', editIndex);
}
}
} function accept(){
if (endEditing()){
var rows = $('#dg').datagrid('getChanges');
var $dg=$('#dg');
if ($dg.datagrid('getChanges').length) {
// var inserted = $dg.datagrid('getChanges', "inserted"); //获取添加状态的行
// var deleted = $dg.datagrid('getChanges', "deleted");//获取删除状态的行
var updated = $dg.datagrid('getChanges', "updated");//获取修改状态的行
var effectRow = new Object();
if (updated.length) {
effectRow["updated"] = JSON.stringify(updated);
}
$.post("/PFK/ashx/UpdateManger.ashx",effectRow, function(rsp) {
debugger;
if(rsp.status){
$.messager.alert("提示", "提交成功!");
$dg.datagrid('acceptChanges');
}
}, "JSON").error(function() {
// $.messager.alert("提示", "提交错误了!");
});
}
}
}
 string updated = context.Request["updated"];
List<ShowCCK_DHModle> modelList = null;
if (updated != "")
{
modelList = RFIDScan.CommFunction.JsonDeserialize<List<ShowCCK_DHModle>>(updated);
}
//获取数据后的其他操作
05-08 08:17