Question
I want to read this XML with using a Ext.data.Model into a ExtJS Store:
<interfaces>
<green>
<name>Eth0</name>
<enabled>true</enabled>
</green>
<red>
<name>Eth1</name>
<enabled>true</enabled>
</red>
</interfaces>
I want to show 'Eth0' and 'Eth1' in the 'name' column of my interfaces grid.
this mapping {name: 'interface', mapping: 'green> name'} only shows Eth0.
how can i do a mapping to show Eth0 and Eth1 in the grid? I should not modify xml file structure.
Thanks in advance
Solution
The record
config of the XmlReader
is a selector specified relative to the root
tag.
To read all child tags of the root as a record, regardless of the name of the tag, we can select all child tags using the > *
selector.
Ext.define('MyModel', {
extend: 'Ext.data.Model',
fields: [ 'name', 'enabled' ],
proxy: {
type: 'ajax',
reader: {
type: 'xml',
root: 'interfaces',
record: '> *'
}
}
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow