PDA

View Full Version : Radiogroup change event fired set to false - Shouldn't be!



catapult
19 Feb 2010, 9:17 AM
I have a tabpanel with a form on each panel. The data from the form is stored in a DB and retrieved when the tabpanel is loaded (displayed on screen).

I populate the form fields with the data values as soon as the tabpanel is loaded. This doesn't quite work for radiobuttons so I have a function which I call when each of the panels is rendered.

This works/has worked really well but I seem to have a problem now. I have a radiogroup with a change listener which fires when I call my radio function to set the radio value. This isn't a problem except that it stops the listener working after that point.

I have done a little digging and found that the radioObj.events.change.fired = false. This I guess is why my listener does not fire.

I do not have this problem with a fresh unpopulated tabpanel where the data is not being loaded so I guess it's something to do with my code.

Here it is, hope someone can help.



var loaderStore = new Ext.data.JsonStore({
url : 'components/formloader.php',
id : 'loaderstore',
root : 'rows',
fields : ['id','value']
});
loaderStore.load();

if(existing!=0)//Not a new case load values
{
loaderStore.on('load', function(){
var rows=loaderStore.data.length;

for(i=0;i<rows;i++)
{
if(Ext.getCmp(loaderStore.getAt(i).data.id)!=undefined)
{
Ext.getCmp(loaderStore.getAt(i).data.id).setValue(loaderStore.getAt(i).data.value);
}
}
});
//End load form values
}

//Set values for hidden radios
function setRadios(form)
{
//Loop through form fields
Ext.each(form.items.items,function(x){
if(x.getXType()=='radiogroup')
{
//Drill down to the radio
Ext.each(x.items.items,function(y){
if(y.getXType()=='radio')
{
//get the id and find value in store
storepointer=loaderStore.find('id',y.id);
if(storepointer>=0)
{
//Set the radios value
Ext.getCmp(y.id).setValue(loaderStore.getAt(storepointer).data.value);
}
}
});
}
else if(x.getXType()=='radio')
{
//get the id and find value in store
storepointer=loaderStore.find('id',x.id);
if(storepointer>=0)
{
//Set the radios value
Ext.getCmp(x.id).setValue(loaderStore.getAt(storepointer).data.value);
}
}
});
}

catapult
22 Feb 2010, 6:45 AM
I have solved my problem so here is what I found. My setRadios function was setting the value of an individual radio button within a radiogroup. I have changed this to set the value of the radiogroup and everything is working fine now.



function setRadios(form)
{
//Loop through form fields
Ext.each(form.items.items,function(x){
if(x.getXType()=='radiogroup')
{
//Drill down to the radio
Ext.each(x.items.items,function(y){
if(y.getXType()=='radio')
{
//get the id and find value in store
storepointer=loaderStore.find('id',y.id);
if(storepointer>=0)
{
//Set the radios value
//Ext.getCmp(y.id).setValue(loaderStore.getAt(storepointer).data.value);
x.setValue(loaderStore.getAt(storepointer).data.value);
}
}
});
}
else if(x.getXType()=='radio')
{
//get the id and find value in store
storepointer=loaderStore.find('id',x.id);
if(storepointer>=0)
{
//Set the radios value
Ext.getCmp(x.id).setValue(loaderStore.getAt(storepointer).data.value);
}
}
});
}