PDA

View Full Version : populating itemselector from xmlstore



joethebarbarian
25 Jan 2011, 12:27 AM
hi. I'm trying to populate an itemselector from an xmlstore, but i can't seem to get it right. The xml is generated via a jsp, hence the url: 'xml.jsp'. I want to be able to use GRANT_CODE as the display and GRANT_DESC as the value. The problem is that the itemselector is empty.

sample xml:


<?xml version="1.0"?>
<ROWSET>
<ROW>
<GRANT_CODE>A</GRANT_CODE>
<GRANT_DESC>Team A</GRANT_DESC>
<GRANT_COMMENT>Football</GRANT_COMMENT>
</ROW>
<ROW>
<GRANT_CODE>B</GRANT_CODE>
<GRANT_DESC>Team B</GRANT_DESC>
<GRANT_COMMENT>Baseball</GRANT_COMMENT>
</ROW>
here's my xmlstore:


var xmlstore = new Ext.data.XmlStore({


storeId: 'myXMLStore',
url: 'xml.jsp',

record: 'ROW',
idPath: 'GRANT_CODE',


fields: [
{name: 'code',
mapping: '@GRANT_CODE'},
{name: 'desc',
mapping: '@GRANT_DESC'}
]
});here's the itemselector (i used the online demo and made minor modifications):


var isForm = new Ext.form.FormPanel({
title: 'XML Test',
width:700,
bodyStyle: 'padding:10px;',
renderTo: 'itemselector',
items:[{
xtype: 'itemselector',
name: 'itemselector',
fieldLabel: 'ItemSelector',
imagePath: 'ext-3.3.1/examples/ux/images/',
multiselects: [{
width: 250,
height: 200,
store: xmlstore,
displayField: 'code',
valueField: 'desc'
},{
width: 250,
height: 200,
store: [['10','Ten']],
tbar:[{
text: 'clear',
handler:function(){
isForm.getForm().findField('itemselector').reset();
}
}]
}]
}],

buttons: [{
text: 'Save',
handler: function(){
if(isForm.getForm().isValid()){
Ext.Msg.alert('Submitted Values', 'The following will be sent to the server: <br />'+
isForm.getForm().getValues(true));
}
}
}]
});