javascript - adding new button "Save and Next" apart from Update and Cancel given in the editable grid of extjs -
please help. using extjs. editable grid has 2 buttons ("update" , "cancel") need add new button "save , next" (saves current row , makes next row editable) in editable grid. can please me achieve this.
if don't mind hands dirty , override extjs code of roweditorbuttons. @ constructor , use ext.define override add button.
here working example:
ext.define('companyname.grid.roweditorbuttons', { override: 'ext.grid.roweditorbuttons', constructor: function(config) { var me = this, roweditor = config.roweditor, editplugin = roweditor.editingplugin; me.callparent(arguments); if(editplugin.saveandnextbtn){ me.insert(0,{ cls: ext.basecssprefix + 'row-editor-update-button', itemid: 'next', handler: editplugin.saveandnext, text: 'save , next', disabled: roweditor.updatebuttondisabled }); } } }); ext.define('companyname.grid.plugin.rowediting', { override: 'ext.grid.plugin.rowediting', saveandnext: function(button){ var ctx = this.context, nextidx = ctx.rowidx + 1, nextrec = ctx.store.getat(nextidx); this.completeedit(); this.startedit(nextrec); } }); ext.create('ext.grid.panel', { store: { fields:[ 'name', 'email', 'phone'], data: [ { name: 'lisa', email: 'lisa@simpsons.com', phone: '555-111-1224' }, { name: 'bart', email: 'bart@simpsons.com', phone: '555-222-1234' }, { name: 'homer', email: 'homer@simpsons.com', phone: '555-222-1244' }, { name: 'marge', email: 'marge@simpsons.com', phone: '555-222-1254' } ] }, columns: [ {header: 'name', dataindex: 'name', editor: 'textfield'}, {header: 'email', dataindex: 'email', flex:1, editor: { xtype: 'textfield', allowblank: false } }, {header: 'phone', dataindex: 'phone'} ], plugins: { ptype: 'rowediting', clickstoedit: 1, saveandnextbtn: true // enable here }, height: 200, width: 400, renderto: ext.getbody() });
Comments
Post a Comment