dddesign
26 Sep 2010, 1:24 PM
my goal is to have one store (with xml reader), on this one a can apply diffrent templates. but I have some problems to understand this and setup the regModel:
first the xml:
<?xml version="1.0"?>
<data>
<forecast_1 location="Nord- und Ostschweiz">
<day>
<name>HEUTE</name>
<temp_high>12°</temp_high>
<temp_low>7°</temp_low>
</day>
<day>
<name>MONTAG</name>
<temp_high>11°</temp_high>
<temp_low>5°</temp_low>
</day>
</forecast_1>
<forecast_2 location="Westschweiz">
<day>
<name>DIENSTAG</name>
<temp_high>12°</temp_high>
<temp_low>7°</temp_low>
</day>
<day>
<name>MITTWOCH</name>
<temp_high>15°</temp_high>
<temp_low>6°</temp_low>
<icon>2.png</icon>
<desc>Sonnig, zeitweise ausgedehnte hohe Wolkenfelder</desc>
</day>
</forecast_2>
<forecast_3 location="Südschweiz">
<day>
<name>DONNERSTAG</name>
<temp_high>14°</temp_high>
<temp_low>7°</temp_low>
</day>
<day>
<name>FREITAG</name>
<temp_high>15°</temp_high>
<temp_low>8°</temp_low>
</day>
</forecast_3>
</data>
second some js:
Ext.regModel('nzz', {
fields: ['name', 'temp_high', 'temp_low']
});
var store_forecast = new Ext.data.Store({
model: 'nzz',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'data.php',
reader: {
type: 'xml',
root: 'data'
}
}
});
tpl1 = new Ext.XTemplate('<tpl for="forecast_1.day">',
'<div id="day"><div class="info_bg_new"><div class="info_glare_new"></div></div><div class="info"><div class="left">{name}</div><div class="middle"></div><div class="right"><p class="temp_high">{temp_high}</p><p class="temp_low">{temp_low}</p></div></div><div class="icon"><img src="img/icon_weather/{icon}" /></div></div>',
'</tpl>')
questions:
<tpl for="forecast_1.day"> this is not working! it's in the docs but the use data={} how can I set it up with a store? probably I have to set up the regModel correctly, but how? <forecast_1> and <day> are nodes...
thanks for your help
j
first the xml:
<?xml version="1.0"?>
<data>
<forecast_1 location="Nord- und Ostschweiz">
<day>
<name>HEUTE</name>
<temp_high>12°</temp_high>
<temp_low>7°</temp_low>
</day>
<day>
<name>MONTAG</name>
<temp_high>11°</temp_high>
<temp_low>5°</temp_low>
</day>
</forecast_1>
<forecast_2 location="Westschweiz">
<day>
<name>DIENSTAG</name>
<temp_high>12°</temp_high>
<temp_low>7°</temp_low>
</day>
<day>
<name>MITTWOCH</name>
<temp_high>15°</temp_high>
<temp_low>6°</temp_low>
<icon>2.png</icon>
<desc>Sonnig, zeitweise ausgedehnte hohe Wolkenfelder</desc>
</day>
</forecast_2>
<forecast_3 location="Südschweiz">
<day>
<name>DONNERSTAG</name>
<temp_high>14°</temp_high>
<temp_low>7°</temp_low>
</day>
<day>
<name>FREITAG</name>
<temp_high>15°</temp_high>
<temp_low>8°</temp_low>
</day>
</forecast_3>
</data>
second some js:
Ext.regModel('nzz', {
fields: ['name', 'temp_high', 'temp_low']
});
var store_forecast = new Ext.data.Store({
model: 'nzz',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'data.php',
reader: {
type: 'xml',
root: 'data'
}
}
});
tpl1 = new Ext.XTemplate('<tpl for="forecast_1.day">',
'<div id="day"><div class="info_bg_new"><div class="info_glare_new"></div></div><div class="info"><div class="left">{name}</div><div class="middle"></div><div class="right"><p class="temp_high">{temp_high}</p><p class="temp_low">{temp_low}</p></div></div><div class="icon"><img src="img/icon_weather/{icon}" /></div></div>',
'</tpl>')
questions:
<tpl for="forecast_1.day"> this is not working! it's in the docs but the use data={} how can I set it up with a store? probably I have to set up the regModel correctly, but how? <forecast_1> and <day> are nodes...
thanks for your help
j