我有一個非常大的itens列表,我想在使用sencha touch的移動應用程序中顯示。該列表已分頁,用戶可以從任何頁面開始查看。 Sencha Touch 2有一個非常好的分頁商店,並且該列表有一個ListPaging插件,它有助於在商品末尾加載新的itens。我正在嘗試改編此插件,以便可以從以前的頁面加載itens。問題是:在我用前一頁重新加載商店之後,如果我將'clearOnPageLoad'配置選項設置爲false,那麼新的itens會附加到列表中,而不是放在開始處。我找不到任何方法來改變這種行爲。任何幫助表示讚賞。如何在使用商店加載前一頁後將itens添加到Sencha Touch 2列表的開頭?
1
A
回答
0
稍微閱讀了Store.js代碼之後,我現在明白會發生什麼:對previousPage的調用只是對loadPage(currentPage - 1)的調用,並且它僅更改ajax調用的參數,因此數據刷新無法知道新數據是應放在當前頁面之前還是之後。
「doDataRefresh」方法是您在更新商店時內部調用的方法。如果addRecords設置爲false,則此方法在加載新數據時清除內部數據數組。如果將其設置爲true,它只是將數據添加到結束:
... (internals of doDataRefresh)
if (operation.getAddRecords() !== true) {
for (i = 0; i < ln; i++) {
record = currentRecords[i];
record.unjoin(me);
// If the record we are removing is not part of the records we are about to add to the store then handle
// the destroying or removing of the record to avoid memory leaks.
if (records.indexOf(record) === -1) {
if (syncRemovedRecords && record.phantom !== true) {
removed.push(record);
}
else if (destroyRemovedRecords && !syncRemovedRecords && !record.stores.length) {
record.destroy();
}
}
}
data.clear();
// This means we have to fire a clear event though
me.fireEvent('clear', me);
}
if (records && records.length) {
// Now lets add the records without firing an addrecords event
me.suspendEvents();
me.add(records);
me.resumeEvents();
}
要徹底解決這個問題,你可以覆蓋存儲方法,以便:
- 的調用「|上一頁」不斷追蹤新數據應放在當前數據之前
- 更改doDataRefresh,以便根據標誌決定是否應在當前商店項目之前或之後添加新數據。
但是,我結束了對商店的分類 - 這對我的用例來說已經足夠了。
相關問題
- 1. 使用商店sencha touch將數據加載到列表中2
- 2. Sencha Touch 2列表/商店
- 3. Sencha Touch 2 - 如何使用ajax/json中止商店加載
- 4. Sencha Touch:使用Rest代理的列表加載商店
- 5. Sencha Touch 2過濾列表商店
- 6. Sencha Touch 2商店不在浮動面板內加載
- 7. 如何將容器添加到sencha touch 2列表中?
- 8. Sencha touch 2 MVC商店
- 9. Sencha Touch 2.2從JSON加載商店,數據轉到原始列
- 10. 如何將元素添加到商店的開頭
- 11. 將嵌套的json綁定到商店,並將商店列入sencha touch 2
- 12. 如何在商店加載之前添加一個面板到店面並在店面加載後刪除
- 13. Sencha Touch - 動態設置商店代理網址,並將商店加載到商品列表中
- 14. 將NavigationView添加到面板sencha touch 2
- 15. Sencha Touch 2 - 將javascript添加到視圖
- 16. Sencha Touch登錄後從商店加載 - 競賽問題?
- 17. sencha touch ajax加載列表
- 18. 如何在Sencha Touch 2的列表中添加項目?
- 19. 如何使用Sencha touch 2從jsp頁面檢索數據到我的商店?
- 20. 如何使用Sencha Touch 2從jsp頁面檢索數據到我的商店
- 21. Sencha Touch Sync商店
- 22. 如何在Sencha Touch中使用一個請求將數據加載到多個商店?
- 23. 如何在同一商店中實現多個url sencha touch 2
- 24. ExtJS - 將標頭添加到AJAX商店
- 25. Sencha Touch 2商店獲取記錄
- 26. Sencha Touch 2商店類型錯誤
- 27. sencha touch ::在列表之前添加一些文本
- 28. Sencha Touch:在商店列表中顯示另一個商店的字段
- 29. Sencha Touch SetActiveItem將圖標添加到TabBar
- 30. 從JSON商店Sencha Touch Carousel
Hi.Am面臨同樣的問題。你能分享你的代碼嗎?可能幫助我。 – Khush 2012-07-25 02:52:39
我回答了我自己的問題,也許只是對您的商店進行整理就足夠了。 – 2012-07-25 17:42:42