-
24 Aug 2012 12:31 PM #1
Answered: CellEditing Listener...
Answered: CellEditing Listener...
I must be doing something really dumb, but I can't figure out how to get Ext.grid.plugin.CellEditing to respond an the edit event. Or any event. I must not be adding the listener correctly. Or in the right place. Or something.
Here's one of the many things I've tried (fragment):
What I would like to do is allow the inline editing function on most cells, but override on a few others. For example, The system name column needs to correlate to a system id table... anyway...Code:items: [{ xtype: 'grid', title: 'plans', store: me.plans, columns: [ { header: 'id', dataIndex: 'id', width : 32}, { header: 'Name', dataIndex: 'name', flex: 1, field : 'textfield' }, { header: 'Description', dataIndex: 'description', flex: 1, field : 'textfield'}, { header: 'System', dataIndex: 'system_name', flex: 1, field : 'textfield',} ], selType: 'cellmodel', plugins: [ Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 2, listeners: [ {edit: function(){console.log("booooo")}} ] }) ], }],
-
Best Answer Posted by scottmartin
See if this works for you:
console:Code:Ext.onReady(function(){ var store = Ext.create('Ext.data.Store', { fields : ['name', 'email', 'change'], data : {'items' : [ { 'name' : 'Lisa', 'email' : 'lisa@simpsons.com', 'change' : 100 }, { 'name' : 'Bart', 'email' : 'bart@simpsons.com', 'change' : -20 }, { 'name' : 'Homer', 'email' : 'home@simpsons.com', 'change' : 23 }, { 'name' : 'Marge', 'email' : 'marge@simpsons.com', 'change' : -11 } ]}, proxy : { type : 'memory', reader : { type : 'json', root : 'items' } } }); var editor = { xtype: 'textfield', allowBlank: false }; var columns = [ { header : 'Name', dataIndex : 'name', locked: true, editor: editor }, { header : 'Email', dataIndex : 'email', flex : 1, editor: editor }, { header : 'Change', dataIndex : 'change', editor: editor } ]; var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1, listeners: { edit: function(){ console.log('boo-who?'); } } }); var grid = Ext.create('Ext.grid.Panel', { title : 'Simpsons', store : store, columns : columns, height : 200, width : 400, renderTo : Ext.getBody(), plugins: [ cellEditing ] }); });
Scott.> boo-who?
-
24 Aug 2012 1:08 PM #2Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,186
- Vote Rating
- 194
- Answers
- 433
See if this works for you:
console:Code:Ext.onReady(function(){ var store = Ext.create('Ext.data.Store', { fields : ['name', 'email', 'change'], data : {'items' : [ { 'name' : 'Lisa', 'email' : 'lisa@simpsons.com', 'change' : 100 }, { 'name' : 'Bart', 'email' : 'bart@simpsons.com', 'change' : -20 }, { 'name' : 'Homer', 'email' : 'home@simpsons.com', 'change' : 23 }, { 'name' : 'Marge', 'email' : 'marge@simpsons.com', 'change' : -11 } ]}, proxy : { type : 'memory', reader : { type : 'json', root : 'items' } } }); var editor = { xtype: 'textfield', allowBlank: false }; var columns = [ { header : 'Name', dataIndex : 'name', locked: true, editor: editor }, { header : 'Email', dataIndex : 'email', flex : 1, editor: editor }, { header : 'Change', dataIndex : 'change', editor: editor } ]; var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1, listeners: { edit: function(){ console.log('boo-who?'); } } }); var grid = Ext.create('Ext.grid.Panel', { title : 'Simpsons', store : store, columns : columns, height : 200, width : 400, renderTo : Ext.getBody(), plugins: [ cellEditing ] }); });
Scott.> boo-who?
-
29 Aug 2012 9:14 AM #3
Scott,
Thank you for the working example. My mistake was adding square brackets around the listeners argument. I am still a little fuzzy why it shouldn't get brackets whereas items, for instance, does... but it doesn't matter, it works!
Thanks again,
--Bo
-
29 Aug 2012 9:49 AM #4Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,186
- Vote Rating
- 194
- Answers
- 433
A listeners is an object, whereas items is an object or array of objects.
Scott.
-
29 Aug 2012 11:18 AM #5
Thank you for de-fuzzifying that for me, Scott!
Cheers,
--Bo


Reply With Quote