2
我試圖從Json-File讀取數據並將其數據輸出到Ext.List中。但我不希望所有記錄都顯示在列表中。我只想顯示前3條記錄。 我已經嘗試過啓動和限制選項,但它仍然不起作用。Sencha Touch:如何設置JsonStore中的數據限制
這裏是我的代碼
型號的一部分:
Ext.regModel('News', {
fields: [
'title',
'description',
'guid'
]
});
查看:
new Ext.List({
"id" : "newsOverview",
"store" : app.stores.newsStore,
"itemTpl" : "{title}",
"listeners" : {
"itemtap" : function(list, index) {
Ext.dispatch({
"controller": 'news',
"action" : "showDetails",
"model" : Ext.ModelMgr.create(list.getStore().getAt(index).data, 'News')
});
}
}
})
商店:
app.stores.newsStore = new Ext.data.Store({
"model" : "News",
"pageSize" : 2,
"proxy" : {
"type" : "ajax",
"url" : 'includes/json/news.json',
"reader" : "json",
"operation" : {
"start" : 0,
"limit" : 2
}
}
});
JSON:
[
{
"title" : "news1",
"description" : "description for news 1",
"date" : "Mon Dec 19 2011 16:23:28 GMT+0100",
"guid" : "11/22/33"
},
{
"title" : "news2",
"description" : "description for news 2",
"date" : "Sun Dec 18 2011 12:23:28 GMT+0100",
"guid" : "22/33/44"
},
{
"title" : "news3",
"description" : "description for news 3",
"date" : "Sat Dec 17 2011 10:22:28 GMT+0100",
"guid" : "33/33/44"
},
{
"title" : "news4",
"description" : "description for news 4",
"date" : "Sat Dec 17 2011 10:21:28 GMT+0100",
"guid" : "43/33/44"
}
]
而該列表應該只輸出news1和news2。 有誰知道如何處理? 我也試過過濾器。我試圖在那裏添加一個計數變量。但是它不在正確的範圍內讀取count變量。 必須有一個簡單的方法來做到這一點。 在此先感謝。
格爾茨 吉爾斯
您能否詳細說明您的答案?我面臨同樣的問題。我不確定如何爲列表實現分頁。 – Khush 2012-07-25 08:42:27