61,112
社区成员
发帖
与我相关
我的任务
分享
<table class="easyui-datagrid" id="dgMat" data-options="toolbar:'#matBar'">
<thead>
<tr>
<th data-options="field:'matId',width:150,halign:'center',align:'center',editor:{
type : 'combobox',
options : {
data: data3,
valueField: 'id',
textField: 'text',
panelHeight: 'auto',
onSelect: function(){
var rows = $('#dgMat').datagrid('getRows');//获取datagrid的所有行
rows[editingId]['names'] = '测试纸'; //获取要编辑的单元格,直接赋值
$('#dgMat').datagrid('endEdit', editingId); //关闭编辑状态(不先关闭直接刷新会导致取消编辑状态并无法再次打开编辑状态)
$('#dgMat').datagrid('refreshRow', editingId); //刷新此行
$('#dgMat').datagrid('beginEdit', editingId); //重新打开编辑状态
}
}
}">物料编号</th>
<th data-options="field:'names',width:120,halign:'center',align:'center'">物料名称</th>
<th data-options="field:'Spec',width:120,halign:'center',align:'center'">规格型号</th>
<th data-options="field:'attr',width:80,halign:'center',align:'center'">物料属性</th>
<th data-options="field:'unit',width:80,halign:'center',align:'center'">基本单位</th>
<th data-options="field:'wastage',width:80,halign:'center',align:'center'">损耗率</th>
<th data-options="field:'safeCount',width:80,halign:'center',align:'center'">安全库存</th>
</tr>
</thead>
</table>
var row = $('#dg').datagrid('getSelected');
if (row) {
var i=$('#dg').datagrid('getRowIndex',row);
var td=$('.datagrid-body td[field="字段名"]')[i];
var div = $(td).find('div')[0];
$(div).text('新值');
}
直接改,最终的dom一样的$('#dg').datagrid('updateRow', {
index: $('#dg').datagrid('getRowIndex',row),
row: {
ProductType: '新名称',
}
});