PDA

View Full Version : How to use XmlReader to map an attribute to an attribute setting on my TextField?



jscolton
1 Nov 2009, 8:10 AM
I have the following XML which is taken from a tutorial:

<?xml version="1.0" encoding="UTF-8"?>
<message success="true">
<contact>
<name>
<first disabled='true'>Jack</first>
<last>Slocum</last>
</name>
<company disabled='true'>Ext JS</company>
<email>[email protected]</email>
<state>OH</state>
<dob>04/15/2007</dob>
</contact>
</message>

Each field is mapped to their relevant ExtJs component as follows (here's a code snippet):

reader : new Ext.data.XmlReader({
record : 'contact',
success: '@success'
}, [
//Want to map the xml attribute to the html input attribute, not to the extjs model object - how to do this??
{name: 'disabled', mapping: '@disabled'},
{name: 'first', mapping:'name/first'}, // custom mapping
{name: 'last', mapping:'name/last'},
'company', 'email', 'state',
{name: 'dob', type:'date', dateFormat:'m/d/Y'} // custom data types
]),

My Question is - how do I also use the "disabled" XML attribute to set whether or not the related ExtJs TextField is disabled or not? Ie it's resulting HTML "disabled" attribute = 'disabled'?

Many thanks
Jeremy