PDA

View Full Version : RESOLVED : form.findField("myField") has no properties



kamelus
18 Aug 2007, 1:43 AM
hi
after searching the forum for the solution to my problem without success i post my problem hoping that someone can help me.
well

i have a dynamic form with a datastore, work perfect, idecided to add a toolbar with buttons

here is the code :


var tb = new Ext.Toolbar('toolbar');

tb.add('-', {
id: 'tbarNew',
icon: 'restart.png', // icons can also be specified inline
cls: 'x-btn-text-icon button', // icon and text class
text:'Nouveau',
pressed: true,
//handler: disable,
tooltip: '<b>Ajouter un nouveau patient</b>'
}, '-');

tb.add('', {
id: 'tbarFirst',
icon: 'images/application/default/grid/page-first.gif', // icons can also be specified inline
cls: 'x-btn-icon',
handler:navigate_records('next') ,
tooltip: '<b>Afficher le premier patient</b>'
}, '');



the handler call the function navigate_records wich for the moment only show a value of the field form like this :



function navigate_records(value){
switch (value)
{
case 'next' : {
Ext.MessageBox.alert('Status', parseInt(form_patient.findField("rec_num").getValue()) +1);
}
case 'previous': {
Ext.MessageBox.alert('Status', parseInt(form_patient.findField("rec_num").getValue()) -1);

}
}

};


When i load my page i have this error message : form_patient.findField("rec_num") has no properties

perhaps it's a scope problem
but i don't know how to resolve this because am just a newbie

if anyone have an idea it will be great

tell me If you need more informations

thanks a lot

kamelus
18 Aug 2007, 8:49 AM
any one has any idea ?

thanks a lot

evant
18 Aug 2007, 9:06 AM
Obvious question:

Where are you declaring form_patient and rec_num

hendricd
18 Aug 2007, 9:17 AM
hi....



function navigate_records(value){
switch (value)
{
case 'next' : {
Ext.MessageBox.alert('Status', parseInt(form_patient.findField("rec_num").getValue()) +1);
}
case 'previous': {
Ext.MessageBox.alert('Status', parseInt(form_patient.findField("rec_num").getValue()) -1);

}
}

};


The first parameter passed by a button handler is the button, thus your handler should look like:


function navigate_records(button, value){


You'll need to navigate_records.createDelegate (http://extjs.com/deploy/ext/docs/output/Function.html#createDelegate)to pass your static value: 'next' properly.



handler:navigate_records.createDelegate(mysteryScope,['next'],true)


...and, your code fragments don't allow much help beyond that.B)

kamelus
18 Aug 2007, 2:32 PM
The first parameter passed by a button handler is the button, thus your handler should look like:


function navigate_records(button, value){


You'll need to navigate_records.createDelegate (http://extjs.com/deploy/ext/docs/output/Function.html#createDelegate)to pass your static value: 'next' properly.



handler:navigate_records.createDelegate(mysteryScope,['next'],true)


...and, your code fragments don't allow much help beyond that.B)

thank you guy the createdelegate solved my problem and here is the complete code i know that it's not the best solution i found but it's a good beginning for a newbie.
Well i used the createDelegate but the pb is that the function navigate_records take the firs argument like an object (it's normal), the second arg like an object and the third like the value 'next' to pass
well
i have added to navigate_records function the code to verify wich button is pressed
and now it's work well

thank you guy for your help

[CODE]
//*************************************** partie r