0
我試圖從商店中獲取圖像,並控制圖像的數量,並顯示每個輪播的12個圖像,所有這些動態取決於數量如果它的商店,如果它達到例如:12,爲其餘創建一個其他的旋轉木馬...... ,但我試圖開始從商店獲取圖像並將其加載到旋轉木馬,但我的看法是空的,沒有什麼是diplaying ..如何從商店動態圖像傳送到傳送帶sencha touch 2
型號:
Ext.define("MyApp2.model.ApplicationModel", {
extend: "Ext.data.Model",
config: {
//type:'tree',
fields: [
{name: 'id', type: 'auto'},
{name: 'name', type: 'auto'},
{name:'icon',type:'image/jpg'}
]
}
});
商店:
var token=localStorage.getItem("access_token");
Ext.define("MyApp2.store.ApplicationStore", {
extend: "Ext.data.Store",
requires: ["Ext.data.proxy.JsonP"],
config: {
model: "MyApp2.model.ApplicationModel",
autoLoad: true,
id :'ApplicationStr',
proxy: {
type: 'jsonp',
url: 'http://mysite.com/api/applications?format=jsonp&access_token='+token,
reader: {
type: 'json',
rootProperty: 'applications'
}
}
}
});
var store = Ext.create('MyApp2.store.ApplicationStore');
store.getStore('ApplicationStr');
myCarousel = Ext.getCmp('carouselid');
store.each(function(record) {
myCarousel.add({
html: '<img src=' + record.get('icon') + '/>'
});
});
的視圖:
Ext.define('MyApp2.view.MainMenu', {
extend: 'Ext.Panel',
requires: ['Ext.TitleBar', 'MyApp2.store.ApplicationStore', 'Ext.dataview.List', 'Ext.Img'],
alias: 'widget.mainmenuview',
config: {
layout: {
type: 'fit'
},
items: [{
xtype: 'titlebar',
title: 'My Apps',
docked: 'top',
items: [
{
xtype: 'button',
text: 'Log Off',
itemId: 'logOffButton',
align: 'right'
}
]
},
{
xtype: "carousel",
id: 'carouselid'
}
],
listeners: [{
delegate: '#logOffButton',
event: 'tap',
fn: 'onLogOffButtonTap'
}]
},
onLogOffButtonTap: function() {
this.fireEvent('onSignOffCommand');
}
});
它的工作原理!我的救星:) – Hasnaa