PDA

View Full Version : XML question



JNason
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.

tryanDLS
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.

JNason
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'}
]
)
});

<reminder>
<ID>001</ID>
<companyID>999</companyID>
<first>John</first>
<last>Smith</last>
<email>[email protected]</email>
<phone>555-555-5555</phone>
<custNum>1234</custNum>
<jobNum>0001</jobNum>
<variantID>55</variantID>
<altVariantID>42</altVariantID>
<notes>Notes Go Here</notes>
<frequencyType>1</frequencyType>
<freqMulti>2</freqMulti>
<messageID>22</messageID>
<useVariant>$1</useVariant>
</reminder>

tryanDLS
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

JNason
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?