View Full Version : XML question

9 Oct 2007, 7:26 AM
At the risk of sounding like a complete *****....

I am trying to pass information to my form using the xml reader. I am able to create the store and input the fields with the reader just fine. My question is whether it is possible to add a few more items to the same xml file and be able to access them and assign them to a js variable. I don't want to put them in as hidden fields, but rather as variables to be use for other purposes in the script.

9 Oct 2007, 7:49 AM
You should be able to just define additional fields to your reader. You don't necessarily have to map them all to form fields.

9 Oct 2007, 8:09 AM
I think I follow you. If I add the ID, messageID, and useVariant fields to the record (ie {name: 'ID'} etc) then I should be able to assign them to a variable? If that is right, how do I assign them to the variable?

var simple = new Ext.form.Form({
labelWidth: 200,

reader : new Ext.data.XmlReader({
record : 'reminder'
}, [
{name: 'first'},
{name: 'last'},
{name: 'email'},
{name: 'phone'},
{name: 'custNum'},
{name: 'jobNum'},
{name: 'variantID'},
{name: 'altVariantID'},
{name: 'notes'},
{name: 'frequencyType'},
{name: 'freqMulti'}

<email>[email protected]</email>
<notes>Notes Go Here</notes>

9 Oct 2007, 8:24 AM
The data is loaded into a collection of Records in the Store. You can access properties of a Record via get http://extjs.com/deploy/ext/docs/output/Ext.data.Record.html#get

9 Oct 2007, 10:37 AM
OK. So then I would use

var msID = record.get("messageID")

to set the value to a variable, right?