{field: 'color', width:250,title:"颜色", editor:{ type:'combobox', options:{ valueField:'data_name', textField:'data_name', onChange:function(newValue,oldValue){ var colorConfig = $(this).combobox('getData'); var rows = $('#manage_btpCommodityDetails_datagrid').datagrid('getRows'); if(colorConfig.length>0){ debugger; var reallyColor = colorConfig.filter(color=> color.data_name = newValue); var index = getRowIndex(this); rows[index].colorName = newValue; rows[index].colorCode = reallyColor[0].date_code; rows[index].skuCode = reallyColor[0].skuCode; rows[index].brand = reallyColor[0].brandName; rows[index].vehicleType = reallyColor[0].modelName; rows[index].customVehicleType = reallyColor[0].customModelName; rows[index].productDescription = reallyColor[0].commodityDescription; } } } } },给没有editor的brand动态赋值
时间: 2024-03-13 12:42:31 浏览: 106
您可以使用datagrid的onLoadSuccess事件,遍历每一行数据,然后给brand字段赋值。示例代码如下:
```
$('#manage_btpCommodityDetails_datagrid').datagrid({
onLoadSuccess: function(data) {
var rows = data.rows;
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
var color = row.color;
if (color) {
var colorConfig = $(this).datagrid('getEditor', {index:i, field:'color'}).target.combobox('getData');
var reallyColor = colorConfig.find(function(color) {
return color.data_name === color;
});
if (reallyColor) {
row.brand = reallyColor.brandName;
}
}
}
}
});
```
在这个示例中,我们首先通过getEditor方法获取到每一行的color编辑器,然后获取到当前选中的颜色reallyColor,最后将reallyColor的brandName字段赋值给brand字段。
阅读全文