【发布时间】:2014-09-11 14:08:27
【问题描述】:
我有网格和行编辑插件...所以我需要获取第一次编辑的记录,当插件启用并显示并且网格中的其他记录单击编辑... 也许是一些“oneditchange”事件,但我在文档中看不到这样的东西。或者干脆阻止编辑这种点击移动编辑的可能性
【问题讨论】:
标签: javascript extjs ext4
我有网格和行编辑插件...所以我需要获取第一次编辑的记录,当插件启用并显示并且网格中的其他记录单击编辑... 也许是一些“oneditchange”事件,但我在文档中看不到这样的东西。或者干脆阻止编辑这种点击移动编辑的可能性
【问题讨论】:
标签: javascript extjs ext4
编辑(编辑器,e,eOpts) 在编辑单元格后触发。使用示例:
grid.on('edit', function(editor, e) {
e.record.commit();
console.log(e.value); // the value you want
});
参数
编辑器:Ext.grid.plugin.CellEditing
e : 对象 具有以下属性的编辑事件:
grid - 网格 record - 被编辑的记录
field - 被编辑的字段名称
value - 正在设置的值 // 你想要的值
originalValue - 字段的原始值,在编辑之前。
row - 网格表行
column - 定义已编辑列的网格列。
rowIdx - 被编辑的行索引
colIdx - 被编辑的列索引
eOpts : 对象
传递给 Ext.util.Observable.addListener 的选项对象。
覆盖:Ext.grid.plugin.Editing.edit
【讨论】:
为了防止在新版本中选择其他网格记录,这会有所帮助
enableEditingProtection: true,
skippingEditingProtection: false,
editingPhantomRecord: false,
initComponent: function() {
var me = this;
me.on('beforeedit', me.onBeforeEdit);
me.on('beforeselect', me.onBeforeSelect);
me.callParent(arguments);
},
skipEditingProtection: function() {
this.skippingEditingProtection = true;
},
onBeforeEdit: function(editor, context) {
if (this.enableEditingProtection &&
!this.skippingEditingProtection &&
editor.editing &&
this.editingPhantomRecord
) {
return false;
}
this.getSelectionModel().select(context.record);
this.editingPhantomRecord = context.record.phantom;
this.skippingEditingProtection = false;
return true;
},
onBeforeSelect: function() {
return !this.enableEditingProtection ||
!this.getPlugin('row-editor') ||
!(this.getPlugin('row-editor').editing && this.editingPhantomRecord);
}
【讨论】: