PDA

View Full Version : How to create listeners object from grid column editor in controller



kiezie
31 Oct 2011, 11:19 PM
Ext.define('PL.view.so.grid', {

extend: 'Ext.grid.Panel',
alias : 'widget.sogrid',
...

columns: [
{dataIndex: 'add', hidden:true, editor: {xtype: 'hiddenfield'}},
{dataIndex: 'id', hidden:true, editor: {xtype: 'hiddenfield'}},
{dataIndex: 'nama', hidden:true, editor: {xtype: 'hiddenfield'}},
{header: 'No', dataIndex: 'no',width:25},
{header: 'penjelasan',
editor: {
xtype: 'autoComplete',
itemId: 'penjelasan',
fields: ['id','nama','harga','diskon','pajak','satuan'],
url: 'store/barangStore.php',
valueField: 'id',
displayField: 'nama',
textTpl: '<tr><td>{id}</td><td>&nbsp;-&nbsp;</td><td>{nama}</td></tr>' //,
// listeners: {
// change: function(combo) {
// alert(combo.getValue());
// }
// }
...


I want that listeners put on controller, so i write in controller like this:


Ext.define('PL.controller.so', {
extend: 'Ext.app.Controller',

models: ['so.barang.list'],
views: ['autoComplete','currencyField'],

init: function() {

this.control({

'sogrid autoComplete[itemId=penjelasan]': {
change: function(combo) { alert(combo.getValue()) }
}


});
}

})


But, it's no working.

what i supposed to do?


thanks,

kiezie

mitchellsimoens
16 Nov 2011, 11:47 AM
You can listen for the edit event on the grid panel that can tell you when editing is done.

inakiabt
29 Nov 2011, 10:50 AM
Same here. But @mitchellsimoens, there is no "edit" event on grid panel.

mitchellsimoens
29 Nov 2011, 5:04 PM
Same here. But @mitchellsimoens, there is no "edit" event on grid panel.

Are you sure? In 4.0.7, I tried the cell-editing.html demo and added a listener to the grid:


plugins: [cellEditing],
listeners : {
edit : function() {
console.log('hi');
}
}

inakiabt
29 Nov 2011, 5:09 PM
You're right. But there is no reference to that event on Grid Panel documentation.
Thanks.

mitchellsimoens
29 Nov 2011, 5:39 PM
You're right. But there is no reference to that event on Grid Panel documentation.
Thanks.

Yeah... I found it digging into the code