PDA

View Full Version : [CLOSED] MVC - Actioncolumn Event fires twice



Michi_72
20 Dec 2012, 7:12 AM
Hello,

after changing to 4.2.0 beta i have the following problem.

In the grid i have configured an action column like this:



{
xtype : 'actioncolumn',
width : 20,
items : [
{
icon : 'system/icons/page_white_acrobat.png',
handler : function(grid, rowIndex, colIndex) {
this.fireEvent('show_pdf', this, grid, rowIndex, colIndex);
}
}
]
}


In the controller the init function looks like this:



init: function() {
this.control({
'system_info actioncolumn': {
show_pdf: this.onShowPDF
}
})
},
onShowPDF: function(view, cell, row, col, e){
console.log('TEST')
}


The console logs the text 'TEST' twice, when the action column is clicked - in 4.1.1 it logs 'TEST' once.

Any tips?

Thanks in advance.

Michi

nohuhu
20 Dec 2012, 11:39 AM
Thanks for reporting this issue, we're looking into it.

Regards,
Alex.

nohuhu
20 Dec 2012, 12:30 PM
Can't reproduce this problem in my setup. Can you post more code please?

Regards,
Alex.

Michi_72
20 Dec 2012, 9:04 PM
Hello,

here is more code for this problem:

The controller code:



Ext.define('AM.controller.system.info', {
extend: 'Ext.app.Controller',
require: 'Ext.ux.RowExpander',
views: [ 'system.info', 'nav.system_details' ],
stores: [ 'nav.system_update' ],
models: [ 'nav.system_update' ],


init: function() {

this.control({

'system_info actioncolumn': {
show_pdf: this.onShowPDF
},
'system_info': {
close: function () {
Ext.getCmp('center_id').getActiveTab().close();
}
},
'system_info grid': {
//Bei diesem Event muss das Layout des Tabs neu gerechnet werden, wegen event. Srollbar...
groupclick: function(view){
view.up('tabpanel').getActiveTab().doLayout();
}
}
});
},

onShowPDF: function(view, cell, row, col, e){ console.log('TEST')
}
});


The view:



Ext.Loader.setPath('Ext.ux', 'system/extjs/examples/ux/');

Ext.require([ 'Ext.ux.RowExpander' ]);

Ext.define('AM.view.system.info' ,{
extend: 'Ext.tab.Panel',
alias : 'widget.system_info',
iconCls : 'settings',
height: 200,
title : 'Systeminformation',
activeTab: 0,

initComponent: function() {

this.items = [
{
xtype : 'system_details',
title : 'Allgemein',
nameColumnWidth : 170,
iconCls : ''
},
{

xtype : 'gridpanel',
title : 'Updateverlauf',
store : 'nav.system_update',
columns : [
{
text : 'Build kalkTOOL',
flex : 1,
dataIndex : 'prg_version',
summaryType : 'count',
summaryRenderer : function(value) {
return ((value === 0 || value > 1) ? '' + value + ' Patches' : '1 Patch');
}
},
{
text : 'Kategorie',
dataIndex : 'prg_kategorie'
},
{
text : 'Datum',
dataIndex : 'prg_time_real',
renderer : Ext.util.Format.dateRenderer('d.m.Y H:i')
},
{
xtype : 'actioncolumn',
width : 20,
items : [
{
icon : 'system/icons/page_white_acrobat.png',
handler : function(grid, rowIndex, colIndex) {
this.fireEvent('show_pdf', this, grid, rowIndex, colIndex);
}
}
]
}
],
viewConfig :
{
stripeRows : true,
loadingText : 'Daten werden geladen...'
},
// toFIX Dieses Plugin ist defekt in 4.2.0 beta
//

plugins : [
{
ptype : 'rowexpander',
rowBodyTpl : ['<p><b>Informationen zum Patch:<br><br></b> {prg_text}</p>'
]
}
]
}

];

this.callParent(arguments);
}
});


The store:



Ext.define('AM.store.nav.system_update',
{
extend : 'Ext.data.Store',
model : 'AM.model.nav.system_update',
autoLoad : true,
groupDir : 'DESC',
groupField : 'prg_time_year',
proxy :
{
type : 'ajax',
url : 'prg/system_updateverlauf/system_updateverlauf_db.php',
reader :
{
root : 'data',
totalProperty : 'count',
id : 'id'
}
}
});



And the model:



Ext.define('AM.model.nav.system_update',
{
extend : 'Ext.data.Model',
fields : [
{
name : 'id',
type : 'int'
},
{
name : 'prg_version'
},
{
name : 'prg_time_real',
type : 'date',
dateFormat : 'Y-m-d H:i:s'
},
{
name : 'prg_time_year',
convert : function(value, record) {
prg_time_year = record.data.prg_time_real.getFullYear();
return prg_time_year;
}
},
{
name : 'prg_kategorie'
},
{
name : 'prg_text'
},
{
name : 'prg_document_path'
}
],
idProperty : 'id'
});


The os is windows 7 and browser is chrome 23.0.1271.97 m.

Thanks!

Michi

Michi_72
2 Jan 2013, 12:50 AM
Hello,

any Ideas? How can i debug where the event is fired?

Thanks!

Michi

nohuhu
8 Jan 2013, 11:10 AM
Hi Michi,

Sorry, holidays intervened. :) Looking into it now.

Regards,
Alex.

nohuhu
8 Jan 2013, 12:10 PM
Still can't reproduce it on the latest codebase. When I click on the icon, console logs 'TEST' once per click. Could it be that you handle this particular event somewhere else and log additional message there?

Regards,
Alex.

Michi_72
8 Jan 2013, 11:12 PM
Hello Alex,

thanks for your reply.

I still think it is a problem with 4.2 beta, cause with 4.1.1 this behaviour is not occured!

Is there a possibility to catch from where the event is fired twice?

When will the next beta or RC1 released?

Thanks!

Michi

nohuhu
9 Jan 2013, 10:22 AM
Michi,

This may have been a problem with 4.2 Beta 1, but since then a big chunk of MVC code has been merged, so the situation has changed. Hey, that's what betas are for! :) Beta 2 should be available Real Soon Now.

As for tracing where it comes from, I'd suggest waiting for Beta 2 and trying this code with it. If it still fires twice, place debugger statement in the event handler and go up the stack to see where the event comes from. Chances are it's a similar chunk of code somewhere else in your application; you can try to differentiate by logging something else than just "TEST".

Regards,
Alex.

medley
19 Mar 2013, 7:00 AM
Hello,

I am using ExtJS 4.2.0 and I have the similar problem. The event is fired twice.

Regards
Medley

ecbelluomini
19 Mar 2013, 6:30 PM
I am with similar problem. Events fires twice using ext js 4.2.0.663gpl.

Attached is an example of the code where the problem occurred.

medley
20 Mar 2013, 12:58 AM
Hello,


My problem is solved.
With Extjs 4.1.1a, I had this code :


var navigation = me.getController('Navigation');
navigation.init();



With Extjs 4.2.0, I have this code :


var navigation = me.getController('Navigation');



I removed the call to the function "init" because it is automatically called when the function getController is called.


Regards
Medley

ecbelluomini
20 Mar 2013, 5:04 PM
Hello.

Removing the call to the init function really solved the problem.

Thank you very much.

DiscoBoy
26 Jun 2013, 8:28 AM
So since ExtJS 4.2 you do not init controllers anymore?
I previously had UI files requiring their own set of controllers and went through this list and inited all controllers on the UI startup...maybe you could add this to your 4.1 -> 4.2 tutorial in the docs...

A short looup also shows that only the application auto inits controllers on getController, not another controller.

nohuhu
26 Jun 2013, 8:48 AM
@DiscoBoy,

You never needed to init() your Controllers manually but there was a bug that prevented automatic init() in certain cases. That bug has been fixed in 4.2.

Regards,
Alex.