您的位置:首页 > 其它

sencha touch2 在control层给panel应用XTemplate模版,并加载store中的数据

2013-10-15 15:04 232 查看


sencha touch2 在control层给panel应用XTemplate模版,并加载store中的数据



model层设置相关字段。

Ext.define("LYT.model.sceneryDetail", {
extend: 'Ext.data.Model',
config: {
fields: ["id","title","content"]
}
});


store层引用model并设置代理

Ext.define("LYT.store.sceneryDetail", {
extend: 'Ext.data.Store',
config: {
model: "LYT.model.sceneryDetail",
storeId: "sceneryDetail",
proxy: {
type: "ajax",
url: "article.json",
reader: {
type: "json",
rootProperty: "data"
}
}
}
});


control层对panel进行相关操作

Ext.define("LYT.controller.sceneryList", {
extend: 'Ext.app.Controller',
config: {
refs: {
getPanel: "#MyPanel"
}
},
launch:function() {
var getController =  this;
var getStore = Ext.data.StoreManager.lookup('sceneryDetail');
getStore.load(function (records, operation, success) {
if (success) {
var tpl = new Ext.XTemplate([
"<h3>{title}</h3>",
"<p>{content}</p>"
]);
var html = tpl.applyTemplate(getStore.getAt(0).getData());
getController.getGetPanel().setHtml(html);
}
});
}
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: