部分代码如下:
{title:'品名',field:'goodsName',width:100,align:'center',
editor:{
type:'combobox',
options:{
valueField: 'eq_name',
textField: 'eq_name',
panelHeight:'120',
queryParams: {
"eqType" : _eqType
},
url:'exammanager/getEquipmentInfo.do',
onSelect: function(rec){
type:'combobox',
options:{
valueField: 'eq_name',
textField: 'eq_name',
panelHeight:'120',
queryParams: {
"eqType" : _eqType
},
url:'exammanager/getEquipmentInfo.do',
onSelect: function(rec){
//获取编辑列所在行的索引
var rowIndex = $(this).parents('.datagrid-row').attr('datagrid-row-index');
//找到对应的列并赋值
$('#consumptionDiv').datagrid('getEditor', { index: rowIndex, field: 'unit' }).target.val(rec.eq_uint);
}
}
}
},
{title:'单位',field:'unit',width:60,align:'center',editor:'text'},
}
}
}
},
{title:'单位',field:'unit',width:60,align:'center',editor:'text'},
品名列 editor 的类型为combobox, 单位列editor类型为text.
品名行中选择不同的设备时, combobox 触发onselect 事件 ,
在onselect事件函数中, 对单位列进行赋值操作, 将从exammanager/getEquipmentInfo.do路径获取到的数据对应的eq_uint(设备单位)属性的值取出, 赋值给单位列.
本文介绍了一种使用Datagrid实现不同列间联动编辑的方法。具体实现为:当选择品名列的下拉框时,会根据所选设备自动填充单位列的值。此功能通过设置combobox类型的editor并在其onSelect事件中获取对应单位值来实现。
161

被折叠的 条评论
为什么被折叠?



