部分代码如下:
{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(设备单位)属性的值取出, 赋值给单位列.