1.与reconfigure事件的冲突问题
假如你的gridpanel要支持动态表头和数据,那么很可能会用到reconfigure,郁闷的是这时候会发现调用reconfigure无法成功,后台报错找不到column.hasEditor()函数。原因是reconfigure之后column的eidtor发生了变化,而RowEditing插件并未随之做出相应调整。解决办法:在grid的beforereconfigure事件中销毁原有的editor
参考文章:http://stackoverflow.com/questions/11963870/using-ext-grid-panel-reconfigure-breaks-the-grids-rowediting-plugin
*原文的解决方案是监听reconfigure事件,测试发现无效,不知道那哥们怎么弄的。
/**
* 解决rowEditing和reconfig冲突的问题
* @event beforeReconfigure
* Fires before a reconfigure.
* @param {Ext.grid.Panel} this
* @param {Ext.data.Store} store The store that was passed to the {@link #method-reconfigure} method
* @param {Object[]} columns The column configs that were passed to the {@link #method-reconfigure} method
*/
beforeReconfigure: function (grid, store, columnConfigs) {
var columns = grid.headerCt.getGridColumns(),
rowEditingPlugin = grid.findPlugin('rowediting');
//
// Re-attached the 'getField' and 'setField' extension methods to each column
//
rowEditingPlugin.initFieldAccessors(columns);
//
// Re-create the actual editor (the UI component within the 'RowEditing' plugin itself)
//
// 1. Destroy and make sure we aren't holding a reference to it.
//
Ext.destroy(rowEditingPlugin.editor);
rowEditingPlugin.editor = null;
//
// 2. This method has some lazy load logic built into it and will initialize a new row editor.
//
rowEditingPlugin.getEditor();
}
2.edit事件:function(editor, context, eOpts)
一般来说在使用RowEditing控件的场景下会希望仅仅向后台提交值发生变化的列,刚开始用了context.record.modified,发现取到的值是grid中最终显示的值即textField,对于combobox、checkbox这类“表里不一”的控件来说就不合适了,我们需要提交的是它的valueField。幸好它还有个表兄弟context.record.getChanges(),这货获取的是货真价实的valueField!