Ext grid中单元格编辑,editor为combobox时用法

Posted 在delphi路上

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ext grid中单元格编辑,editor为combobox时用法相关的知识,希望对你有一定的参考价值。

 

{
header: \'TO_PTN_NM\',
dataIndex: "TO_PTN_NM",
sortable: true,
renderer: function (v, m, recod, rowindex, colindex) {
if (true) {
m.style = " background-color: #ccffcc;";
};
return v;
},
editor: {
//xtype: \'textfield\', selectOnFocus: true
xtype: \'combo\', selectOnFocus: true,
forceSelection: false,
value: \'\',
editable: false,
typeAhead: false,
store: Ext.create("Scripts.Code.MDM.Logistic.Delivery.DeliveryAttribute.store.HandOverTakeOverReasonStore"),
//tpl: Ext.create(\'Ext.XTemplate\',
// \'<tpl for=".">\',
// \'<div class="x-boundlist-item">{COMM_CODE}:{COMM_CODE_NM}</div>\',
// \'</tpl>\'
// ),
queryMode: \'local\',
//queryParam: \'COMM_CODE\',
valueField: \'COMM_CODE_NM\',
displayField: \'COMM_CODE_NM\',
//hiddenName: \'COMM_CODE\',
matchFieldWidth: false,//此处要有
listConfig: { width: 200 },
listeners: {
//focus: function (combo, The, eOpts) {
// var grid = combo.up("grid");
// var store = grid.getStore("DeliveryAttributeStore");
// var rowindex = grid.normalGrid.editingPlugin.context.rowIdx;
// var gridrecord = store.data.items[rowindex];
// //
// var delivery = gridrecord.data.TO_GUBUN_CODE;
// var thisStore = combo.getStore();
// var obj = new Object();
// obj.DeliveryKind = delivery;
// thisStore.proxy.extraParams = obj;
// thisStore.load();
//},
change: function (combo, newValue, oldValue, eOpts) {
var grid = combo.up("grid");
var store = grid.getStore("DeliveryAttributeStore");
var rowindex = grid.normalGrid.editingPlugin.context.rowIdx;//这个grid中有锁定的列 var rowindex = grid.lockedGrid.editingPlugin.context.rowIdx;
var gridrecord = store.data.items[rowindex];
gridrecord.set(\'TO_PTN_CODE\', combo.valueModels[0].data.COMM_CODE);
gridrecord.set(\'TO_PTN_NM\', combo.rawValue);
//console.log(gridrecord);
}
}
}
},

//

{
header: "T/O", dataIndex: "TO_CODE",
renderer: function (value, metadata, record) {
metadata.style = \'cursor: pointer;\';
metadata.class = "variablediv";
return "<span style=\'color:blue;width:100%\' class=\'TO\'>" + value + "</span>";
}
},

cellclick: function (grid, td, cellIndex, record, tr, rowIndex, e, eOpts) {
var t = e.getTarget();
record = grid.getStore().getAt(rowIndex);
var control = t.className;
if (control == "TO") {
var TO = record.get("TO_CODE");
var hasWindow = Ext.ComponentQuery.query("Ali_TODetailInfoWindow");
var window;
if (hasWindow.length == 0) {
window = Ext.create("Scripts.Code.PM.ProdPreparation.TransferOrder.TOPlan.view.TODetailInfoWindow", {
closeAction: \'destroy\'
});//Ext.widget("Ali_TODetailInfoWindow");
}
else {
window = hasWindow[hasWindow.length - 1];
};

window.show();
var plangrid = window.down(\'grid[name=syncplan]\');
var planstore = plangrid.getStore();
planstore.proxy.extraParams = {
TO: TO
};
//planstore.on(\'load\', function () {
// mergeGrid(plangrid, [1], false);//, 3, 4, 6
//});
planstore.loadPage(1);
var slipgrid = window.down(\'grid[name=slipstatus]\');
var slipstore = slipgrid.getStore();
slipstore.proxy.extraParams = {
TO: TO
};
slipstore.loadPage(1);
//console.log(record);
var rec = new Object({
TO_NO: record.data.TO_CODE,
MODEL_CODE: record.data.MODEL_CODE,
PO_NO: record.data.PO_CODE,
MOVE_PLAN_QTY: record.data.PLAN_QTY_CODE,
MODEL_DESC: record.data.MODEL_NM_CODE
});
var form = window.down(\'form\');
form.getForm().setValues(rec);
}
},

以上是关于Ext grid中单元格编辑,editor为combobox时用法的主要内容,如果未能解决你的问题,请参考以下文章

extjs 4.0 鼠标编辑完单元格后离开单元格的事件?

在extjs经典网格中开始编辑单元格

请问:ext中对于可编辑的grid,如何将光标聚焦到某个单元格中?

在行分组级别 ag-grid 启用对单元格字段的编辑

EXT grid单元格点击时判断当前行是否可编辑

Ext JS 6学习文档-第5章-表格组件(grid)