PDA

View Full Version : Combobox loaded remotely and scriptTagProxy question..



ImperioG
10 Oct 2010, 4:13 PM
Hi! (sorry for my english..)

I'm trying to populate this combobox remotely but i can't figure out what is wrong with the code.. it works fine when i configure it to work locally but when i link the store to the remote url it doesn't load anything.. the code is very simple where is the error?? .. firebug doesn't show me any error .. therefore .. if i well intended the autoLoad property should fire the load action on the store as soon as possible right? Why it doesn't works in this example (i had to implement an afterender event to load the store..)?

live example (http://www.zxbyte.com/GeoEvent/)

the code:


Ext.onReady(function() {
new Ext.Window({
x:0,
y:0,
width:300,
height:450,
items:[
{xtype:'form',
title:'Form',
id:'testForm',
width:'100%',
layout:'form',
items:[
{
fieldLabel : 'Mezzo',
name : 'mz',
xtype : 'combo',
displayField : 'descrizione',
autoLoad:true,
//mode : 'local',
mode : 'remote',
emptyText : 'seleziona un mezzo...',
store : new Ext.data.XmlStore({
record:'mezzo',
//url:'data/mezzi.xml'
url:'leggimezzi.php',
fields:['descrizione']
}),
listeners:
{
afterrender:function(){this.store.load();}
}
}
]
}
]
}).show();
});


about the scripttagproxy question.. i read several examples (like this (http://www.java2s.com/Code/JavaScript/Ext-JS/UseaScriptTagProxytofetchcrossdomainremotedata.htm)) implementing the scripttagproxy but they didn't use the callback parameter at all.. can someone explain me better this concept? this parameter must point to a real implementation of this callback function?

thanks very much for your help!!..

Condor
11 Oct 2010, 1:16 AM
1. You probably want to configure your combobox with triggerAction:'all'.

2. Do not use width:'100%'. Instead, make your window layout:'fit'.

3. You know you can't use a ScriptTagProxy with XML?

Animal
11 Oct 2010, 1:36 AM
But with that being a relative URL, there's no need to use ScriptTagProxy. It's random coding.

ImperioG
11 Oct 2010, 5:47 PM
thanks for your answers they were useful..


You probably want to configure your combobox with triggerAction:'all'Ok Condor, setting that property if i press the down arrow the combobox load the store but the autocomplete function still doesn't work in the remote version..
why it work properly in the local version and not remotely?? what i'm missing??

try the live example (http://www.zxbyte.com/GeoEvent/).. now it shows both the versions .. the behaviour is different and i don't know why..


But with that being a relative URL, there's no need to use ScriptTagProxy. It's random coding. i setup an XmlStore on the fly is some other property needed to work remotely? some property to set in the form-panel configuration?
about the STProxy i simple didn't understood well the callback property and how to use it.. sorry if i didn't explain myself right ..

i report the code regarding the 2 comboboxes


Ext.onReady(function() {
new Ext.Window({
x:20,
y:20,
width:300,
height:250,
items:[
{xtype:'form',
title:'Form',
id:'testForm',
layout:'form',
items:[
{
fieldLabel : 'Remote',
name : 'mz_r',
xtype : 'combo',
triggerAction:'all',
displayField : 'descrizione',
autoLoad:true,
mode : 'remote',
emptyText : 'seleziona un mezzo...',
store : new Ext.data.XmlStore({
record:'mezzo',
url:'leggimezzi.php',
fields:['descrizione']
}),
listeners:
{
afterrender:function(){this.store.load();}
}
},
{
fieldLabel : 'Local',
name : 'mz_l',
xtype : 'combo',
displayField : 'descrizione',
autoLoad:true,
mode : 'local',
emptyText : 'seleziona un mezzo...',
store : new Ext.data.XmlStore({
record:'mezzo',
url:'data/mezzi.xml',
fields:['descrizione']
}),
listeners:
{
afterrender:function(){this.store.load();}
}
}
]
}
]
}).show();
});thanks very much for your help..

Condor
11 Oct 2010, 11:19 PM
In remote mode autoComplete starts working after typing minChars (defaults to 4).

ImperioG
12 Oct 2010, 7:58 PM
thanks Condor i missed that property but it wasn't the cause of the problem. I read more carefully the documentation and i solved the question: the property 'mode' must be set to '_local_' even for the remote combobox!.. the autocomplete function didn't work because the remote mode force to load the entire store each time.. i hope this could be useful for other users!!
Any suggest about the scriptTagProxy question?

Animal
12 Oct 2010, 11:34 PM
Yes. As I said, you don't need to use it!

Condor
12 Oct 2010, 11:51 PM
1. mode:'remote' is especially useful when using triggerAction:'query'. For triggerAction:'all' I would indeed suggest to preload the store and use mode:'local'.

2. Why are you interested in ScriptTagProxy? You don't have to make requests to a different domain and your are using XML. Both reasons why you don't need/can't use ScriptTagProxy.