PDA

View Full Version : Dynamic carousel inside TapPanel not working



jimmy6
17 Mar 2012, 9:50 PM
1) How to get 'title' and 'description' inside function(records, operation, success) . The print out in window.alert("records.data = "+records.length); is 20
2) The current code just showing one empty carousel page only. It should show 20 pages with {title}.
3) How to make sure my model map correctly?





Ext.application({
name: 'test',

launch: function() {
Ext.define('News', {
extend: 'Ext.data.Model',
config: {
fields: ['title','description']
}
});


var newsStore = Ext.create('Ext.data.Store', {
model: 'News',
proxy: {
type: 'ajax',
url : '/testurl',
reader: {
type: 'xml',
record: 'item',
rootProperty: 'channel'
}
}
});
newsStore.load({
callback: function(records, operation, success) {
var channel = newsStore.first();
window.alert("channel = "+channel);
window.alert("records.data = "+records.length);
window.alert("record0].get('title'= "+records[0].data.title);
console.log(records[0]);


},
scope: this
});
var tap = Ext.create('Ext.TabPanel', {
fullscreen: true,
tabBarPosition: 'bottom',


items: [

{
xtype: 'carousel',
title: 'Blog',
iconCls: 'star',
id: 'carouselNews',
items: new Ext.DataView({
cls: 'atr-question-card',
store: Ext.data.StoreManager.lookup('newsStore'),

itemTpl: new Ext.XTemplate(
'<tpl for=".">',

'<div class="question">{title} </div>',

'</tpl>'
)
} )


},

]
}

);

}
});

jimmy6
17 Mar 2012, 11:08 PM
The title only can be printed out if i am using console.log(newsStore.data.all[0].data.title); . But the page it is one and empty.