Ext.grid.plugin.CellEditing-associationSupport.js (1762B)
1 /** 2 * Overrides the editing plugin to support editing of associations. 3 */ 4 Ext.define('PartKeepr.grid.plugin.CellEditing', { 5 alias: 'plugin.cellediting', 6 extend: 'Ext.grid.plugin.Editing', 7 override: 'Ext.grid.plugin.CellEditing', 8 requires: ['Ext.grid.CellEditor', 'Ext.util.DelayedTask'], 9 10 onEditComplete: function (ed, value, startValue) 11 { 12 var me = this, 13 context = ed.context, 14 view, record; 15 16 view = context.view; 17 record = context.record; 18 context.value = value; 19 if (!me.validateEdit(context)) { 20 me.editing = false; 21 return; 22 } 23 24 // Only update the record if the new value is different than the 25 // startValue. When the view refreshes its el will gain focus 26 if (!record.isEqual(value, startValue)) { 27 if (record.hasField(context.column.dataIndex)) { 28 record.set(context.column.dataIndex, value); 29 } else { 30 if (record.associations[context.column.dataIndex]) { 31 var setterName = record.associations[context.column.dataIndex].setterName; 32 33 record[setterName](value); 34 } 35 } 36 // Changing the record may impact the position 37 context.rowIdx = view.indexOf(record); 38 } 39 40 me.fireEvent('edit', me, context); 41 42 // We clear down our context here in response to the CellEditor completing. 43 // We only do this if we have not already started editing a new context. 44 if (me.context === context) { 45 me.setActiveEditor(null); 46 me.setActiveColumn(null); 47 me.setActiveRecord(null); 48 me.editing = false; 49 } 50 }, 51 });