PDA

View Full Version : [SOLVED] 2.0 Combobox from XML not filling



fendrikat
8 Dec 2007, 2:03 PM
Hi all,
..first of all, thanks so much for all the help provided in the numerous posting in the forum, being kind of new to Javascript and ExtJS, it really helped me going quite. However, I have a problem now where I couldn't find anywhere a solution and I think I must really be stupic missing something very basic and easy. Basically, I am not getting a COmbobox ffilled from XML file, while it works fine from SimpleStore-Array. Using Ext 2.0 Beta 1, same in FF and IE.

JS Code:


var oRec = Ext.data.Record.create([
{name: 'SelID' },
{name: 'SelText'}
]);

var oReader = new Ext.data.XmlReader({
record: 'Item',
id: 'SelID'
}, oRec);

var oProxy = new Ext.data.HttpProxy({
method:'get',
url: 'NeApLib/Retrieve/GenRefProxy.php'
});

var oComboStore = new Ext.data.Store({
fields: ['SelID', 'SelText'],
proxy: oProxy,
reader: oReader
});

var aRet = new Ext.form.ComboBox({
cls: 'NeApStdFieldHeight',
fieldLabel: cL1,
disabled: bDisab,
hiddenName: cF1,
name: cF1,
valueField: 'SelID',
displayField: 'SelText',
mode: 'remote',
anchor:'95%',
store: oComboStore
});

oComboStore.load();



XML file from server:


<?xml version='1.0' ?>
<Item>
<SelID>1</SelID>
<SelText>TestSel 1</SelText>
</Item>


Any help and support would be very much appreciated, I checked in numerous postings and in the API and I cant find any mistake. Also, no error is shown in FireBug at all, just the data does not appear in the combobox.
Frank

hendricd
8 Dec 2007, 2:38 PM
Got Content-Type: text/xml in your response headers?

fendrikat
8 Dec 2007, 2:51 PM
Got Content-Type: text/xml in your response headers?

Hi Doug,
..yes, pls see header below:



Date Sat, 08 Dec 2007 22:19:01 GMT
Server Apache/2.2.6 (Win32) mod_ssl/2.2.6 OpenSSL/0.9.8g PHP/5.2.5
X-Powered-By PHP/5.2.5
Vary Accept-Encoding,User-Agent
Content-Encoding gzip
Content-Length 99
Keep-Alive timeout=5, max=83
Connection Keep-Alive
Content-Type text/xml

Should be ok, I would guess..?

hendricd
8 Dec 2007, 2:58 PM
Looks fine so far.

You should setup a 'loadexception' event handler for the store; could be enlightening. ;)

fendrikat
8 Dec 2007, 3:09 PM
Looks fine so far.

You should setup a 'loadexception' event handler for the store; could be enlightening. ;)

..done...set up an loadexception handler for the store, while I see in the console that the file is loading, no exception occurs - and no data is displayed in the combobox...thanks a lot for the help....



var aRet = new Ext.form.ComboBox({
cls: 'NeApStdFieldHeight',
fieldLabel: cL1,
disabled: bDisab,
hiddenName: cF1,
name: cF1,
valueField: 'SelID',
displayField: 'SelText',
mode: 'remote',
anchor:'95%',
store: oComboStore
});

aRet.store.on('loadexception',exceptionHandler);




//exception handler
function exceptionHandler(proxy, o, arg, e){
var repTx = Ext.util.JSON.decode(arg.responseText);
Ext.MessageBox.alert(lblError, repTx.info);
};

tryanDLS
8 Dec 2007, 3:16 PM
First of all, if you're still using the beta code, update to the final release. Use the ext-all-debug file and set a BP in firebug in the store.loadRecords function - is it getting there?

fendrikat
8 Dec 2007, 3:18 PM
First of all, if you're still using the beta code, update to the final release. Use the ext-all-debug file and set a BP in firebug in the store.loadRecords function - is it getting there?

Hi Tim,
OK, will do the upgrade to final and try my luck debugging through it....
Thanks a lot,
Frank

fendrikat
8 Dec 2007, 3:41 PM
First of all, if you're still using the beta code, update to the final release. Use the ext-all-debug file and set a BP in firebug in the store.loadRecords function - is it getting there?

Hi Tim,
..did the update, din't change anything.

I debuged through it, below functions wheer called:
Ext.extend(Ext.data.HttpProxy, Ext.data.DataProxy, .load
Ext.extend(Ext.data.Connection, Ext.util.Observable, .request

store.loadRecords was reached by other XMl processing done in the App, but not related to the combobox data store....so seems before this something goes wrong....?

tryanDLS
8 Dec 2007, 4:35 PM
Try wrapping your xml with an outer element container. The query engine needs to start at a node at least 1 level higher than what it's looking for e.g. the Item.



<Items><Item>....</Item></Items>
or



<response success="true">
<Item>....</Item>
</response>


Also, method in your proxy should be 'GET' to follow the conventions.

fendrikat
9 Dec 2007, 5:37 AM
Try wrapping your xml with an outer element container. The query engine needs to start at a node at least 1 level higher than what it's looking for e.g. the Item.



<Items><Item>....</Item></Items>
or



<response success="true">
<Item>....</Item>
</response>


Also, method in your proxy should be 'GET' to follow the conventions.

Hi Tim,
...thanks a lot, that made it! I tried with the <response> and it worked and also tried with:


<Main>
<Item>
<SelID>1</SelID>
<SelText>TestSel 1</SelText>
</Item>
<Item>
<SelID>2</SelID>
<SelText>TestSel 2</SelText>
</Item>
<Item>
<SelID>3</SelID>
<SelText>TestSel 3</SelText>
</Item>
</Main>


and it works as well.
Thanks a lot for everyone for the help and support,
Frank

fendrikat
9 Dec 2007, 6:03 AM
...just one remark for anybody working on this as well - at least for me, the list data for the combobox is for me only populated, if I pass a value for that field in the form.

For ComboBoxes, which do not have values passed for them, no selection list is populated. Not sure if this behavior is on purpose, but good to know when testing ;)