Something wrong with my XML?
i'm parsing an xml with my extjs but it returns only one of the five components.
only the first one of the five components.
Ext.regModel('Card', {
fields: ['investor']
});
var store = new Ext.data.Store({
model: 'Card',
proxy: {
type: 'ajax',
url: 'xmlformat.xml',
reader: {
type: 'xml',
record: 'investors'
}
},
listeners: {
single: true,
datachanged: function(){
Ext.getBody().unmask();
var items = [];
store.each(function(rec){
alert(rec.get('investor'));
});
and my xml file is:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<investors>
<investor>Active</investor>
<investor>Aggressive</investor>
<investor>Conservative</investor>
<investor>Day Trader</investor>
<investor>Very Active</investor>
</investors>
<events>
<event>3 Month Expiry</event>
<event>LEAPS</event>
<event>Monthlies</event>
<event>Monthly Expiries</event>
<event>Weeklies</event>
</events>
<prices>
<price>$0.5</price>
<price>$0.05</price>
<开发者_StackOverflow;price>$1</price>
<price>$22</price>
<price>$100.34</price>
</prices>
</root>
wen i run the code only "Active" comes out. . . .
i know that i'm doing something wrong but i'm not sure what....
please help . . . . .
Every thing was fine execpt that my xml format should be like this:
Active 3 Month Expiry $0.5 Aggressive LEAPS $0.05 Conservative Monthlies $1 Day Trader Monthly Expiries $22 Very Active Weeklies $100.34
<?xml version="1.0" encoding="UTF-8"?>
<main>
<root>
<investor>Active</investor>
<event>3 Month Expiry</event>
<price>$0.5</price>
</root>
<root>
<investor>Aggressive</investor>
<event>LEAPS</event>
<price>$0.05</price>
</root>
<root>
<investor>Conservative</investor>
<event>Monthlies</event>
<price>$1</price>
</root>
<root>
<investor>Day Trader</investor>
<event>Monthly Expiries</event>
<price>$22</price>
</root>
<root>
<investor>Very Active</investor>
<event>Weeklies</event>
<price>$100.34</price>
</root>
</main>
You need to visit the sencha.com tutorial on how to use XML with a grid. XML Grid Sample
You should take not of how to properly structure your XML so that it can be consumed by a data store.
The Ext XML grid needs to be configured to look for the repeating elements to map to each record in your store/grid. You had it configured for investors
, of which there is only 1. Then you mapped a field for investor
and it is just grabbing the first one that it encounters for the "column" of that "row".
The repeating element for your "rows" in the grid should be investor
, not investors
.
Change: record: 'investors'
to: record: 'investor'
精彩评论