if (editor && editor.onColumnAdd) { editor.onColumnAdd(column); } } }, // private onColumnRemove: function(ct, column) { if (column.isHeader) { var me = this, editor = me.getEditor();
if (editor && editor.onColumnRemove) { editor.onColumnRemove(column); } me.removeFieldAccessors(column); } }, // private onColumnResize: function(ct, column, width) { if (column.isHeader) { var me = this, editor = me.getEditor();
if (editor && editor.onColumnResize) { editor.onColumnResize(column, width); } } }, // private onColumnHide: function(ct, column) { // no isHeader check here since its already a columnhide event. var me = this, editor = me.getEditor(); if (editor && editor.onColumnHide) { editor.onColumnHide(column); } }, // private onColumnShow: function(ct, column) { // no isHeader check here since its already a columnshow event. var me = this, editor = me.getEditor(); if (editor && editor.onColumnShow) { editor.onColumnShow(column); } }, // private onColumnMove: function(ct, column, fromIdx, toIdx) { // no isHeader check here since its already a columnmove event. var me = this, editor = me.getEditor(); if (editor && editor.onColumnMove) { editor.onColumnMove(column, fromIdx, toIdx); } }, // private setColumnField: function(column, field) { var me = this; me.callParent(arguments); me.getEditor().setField(column.field, column); } });
Ext.define('Ext.grid.plugin.RowEditing', {
extend: 'Ext.grid.plugin.Editing',
alias: 'plugin.rowediting', requires: [
'Ext.grid.RowEditor'
], editStyle: 'row',
autoCancel: true,
errorSummary: true,
constructor: function() {
var me = this;
me.callParent(arguments); if (!me.clicksToMoveEditor) {
me.clicksToMoveEditor = me.clicksToEdit;
} me.autoCancel = !!me.autoCancel;
},
destroy: function() {
var me = this;
Ext.destroy(me.editor);
me.callParent(arguments);
},
startEdit: function(record, columnHeader) {
var me = this,
editor = me.getEditor(); if (me.callParent(arguments) === false) {
return false;
} // Fire off our editor
if (editor.beforeEdit() !== false) {
editor.startEdit(me.context.record, me.context.column);
}
}, // private
cancelEdit: function() {
var me = this; if (me.editing) {
me.getEditor().cancelEdit();
me.callParent(arguments);
}
}, // private
completeEdit: function() {
var me = this; if (me.editing && me.validateEdit()) {
me.editing = false;
me.fireEvent('edit', me.context);
}
}, // private
validateEdit: function() {
var me = this;
return me.callParent(arguments) && me.getEditor().completeEdit();
}, // private
getEditor: function() {
var me = this; if (!me.editor) {
me.editor = me.initEditor();
}
return me.editor;
}, // private
initEditor: function() {
var me = this,
grid = me.grid,
view = me.view,
headerCt = grid.headerCt; return Ext.create('Ext.grid.RowEditor', {
autoCancel: me.autoCancel,
errorSummary: me.errorSummary,
fields: headerCt.getGridColumns(),
hidden: true, // keep a reference..
editingPlugin: me,
renderTo: view.el
});
}, // private
initEditTriggers: function() {
var me = this,
grid = me.grid,
view = me.view,
headerCt = grid.headerCt,
moveEditorEvent = me.clicksToMoveEditor === 1 ? 'click' : 'dblclick'; me.callParent(arguments); if (me.clicksToMoveEditor !== me.clicksToEdit) {
me.mon(view, 'cell' + moveEditorEvent, me.moveEditorByClick, me);
} view.on('render', function() {
// Column events
me.mon(headerCt, {
add: me.onColumnAdd,
remove: me.onColumnRemove,
columnresize: me.onColumnResize,
columnhide: me.onColumnHide,
columnshow: me.onColumnShow,
columnmove: me.onColumnMove,
scope: me
});
}, me, { single: true });
}, startEditByClick: function() {
var me = this;
if (!me.editing || me.clicksToMoveEditor === me.clicksToEdit) {
me.callParent(arguments);
}
}, moveEditorByClick: function() {
var me = this;
if (me.editing) {
me.superclass.startEditByClick.apply(me, arguments);
}
}, // private
onColumnAdd: function(ct, column) {
if (column.isHeader) {
var me = this,
editor;
me.initFieldAccessors(column);
editor = me.getEditor();
if (editor && editor.onColumnAdd) {
editor.onColumnAdd(column);
}
}
}, // private
onColumnRemove: function(ct, column) {
if (column.isHeader) {
var me = this,
editor = me.getEditor();
if (editor && editor.onColumnRemove) {
editor.onColumnRemove(column);
}
me.removeFieldAccessors(column);
}
}, // private
onColumnResize: function(ct, column, width) {
if (column.isHeader) {
var me = this,
editor = me.getEditor();
if (editor && editor.onColumnResize) {
editor.onColumnResize(column, width);
}
}
}, // private
onColumnHide: function(ct, column) {
// no isHeader check here since its already a columnhide event.
var me = this,
editor = me.getEditor(); if (editor && editor.onColumnHide) {
editor.onColumnHide(column);
}
}, // private
onColumnShow: function(ct, column) {
// no isHeader check here since its already a columnshow event.
var me = this,
editor = me.getEditor(); if (editor && editor.onColumnShow) {
editor.onColumnShow(column);
}
}, // private
onColumnMove: function(ct, column, fromIdx, toIdx) {
// no isHeader check here since its already a columnmove event.
var me = this,
editor = me.getEditor(); if (editor && editor.onColumnMove) {
editor.onColumnMove(column, fromIdx, toIdx);
}
}, // private
setColumnField: function(column, field) {
var me = this;
me.callParent(arguments);
me.getEditor().setField(column.field, column);
}
});
Ext.getCmp('addqst').setDisabled(true);
Ext.getCmp('modifyqst').setDisabled(true);
Ext.getCmp('up').setDisabled(true);
Ext.getCmp('down').setDisabled(true);
var rowEditor=rowEditing.getEditor();
rowEditor.on('hide',function(){
var name="";
if(myStore.getCount()!=0){
name=myStore.getAt(myStore.getCount()-1).data.name;
}else{
name="flag";
}
if(name=="" || name==null){
myStore.removeAt(myStore.getCount()-1);
}
Ext.getCmp('addqst').setDisabled(false);
Ext.getCmp('modifyqst').setDisabled(false);
Ext.getCmp('up').setDisabled(false);
Ext.getCmp('down').setDisabled(false);
if(myStore.getCount()>=10){
Ext.getCmp('addqst').setDisabled(true);
}
return false;
});
});