PDA

View Full Version : Pass parameters with a button handler



senacle
17 Jun 2010, 11:02 PM
I' ve a formpanel with somefield.
I've a panel with some buttons.
When i click on the buttons, I want to pass the value of formpanel field with the handler.

Some field in the FormPanel


.....
new Ext.form.ComboBox({
....
id: 'idjs_stat_domaine',
....
})
.....


Some button in the Panel :



.....
id: 'idjs_imprimer_signales',
.....
handler: function_imprimer_pdf.createCallback(Ext.getCmp('date_stat_debut').getValue(), Ext.getCmp('date_stat_fin').getValue(), Ext.getCmp('idjs_stat_categorie').getValue(), Ext.getCmp('idjs_imprimer_signales'), 'signales')
.....


The function :


var function_imprimer_pdf = function (date_debut, date_fin, categorie, bouton, statut) {
alert('date_debut : ' + date_debut + ' date_fin : ' + date_fin + ' categorie : ' + categorie + ' statut : ' + statut);
.....
}


In the first load of my web page, date_fin is set with a value.
I choose some value for the fields in the FormPanel.

Then, when i click on the button, i've this :
date_debut : date_fin : Fri Jun 18 2010 00:00:00 GMT+0200 categorie : statut : en_cours

So, it seems, that the parameters in the handler are set the first time the page is load. After, when i choose value in the FormPanel fields, they aren't pass to the handler.

When i use a handler without function :



.....
handler: function () {
var mask = new Ext.LoadMask(Ext.getBody(), {msg:"Impression en cours..."});
var date_debut = Ext.getCmp('date_stat_debut').getValue();
var date_fin = Ext.getCmp('date_stat_fin').getValue();
var categorie = Ext.getCmp('idjs_stat_categorie').getValue().split("__");
categorie = categorie[0];
alert('date_debut : ' + date_debut + ' date_fin : ' + date_fin + ' categorie : ' + categorie + ' statut : ' + statut);
.....


I've the good values of the parameters.

SO, what i'm missing ?

senacle
19 Jun 2010, 5:52 AM
Sorry for multiple post.

See

http://www.sencha.com/forum/showthread.php?101960-Pass-parameters-with-a-button-handler