[英]Load items on demand for NestedList in Sencha Touch
我正在使用Sencha Touch構建類似於電子郵件的應用程序,並且將NestedList小部件用於導航面板。
收件箱中可能有很多郵件,因此我想按需加載,當用戶滾動到列表的末尾時,它將自動加載下10個項目並將新項目追加到列表中。
我該如何實現?
您可以嘗試以下操作:
var loadingItems = false;
var fetchItems = function () {
//fetch new items to add
loadingItems = false;
};
//nestedList: reference to the nestedList
//x: new x position
//y: new y position
var scrollListener = function(nestedList, x, y) {
//set some boundary for where we should start loading data
var screenBottom = nestedList.getHeight() - OFFSET;
//if we're within some region near the bottom of the list...
if((y >= screenBottom) && !loadingItems) {
loadingItems = true;
fetchItems();
}
};
nestedList.addListener("move", scrollListener);
由於Sencha Touch與ExtJS共享了大量代碼,因此您可以通過查看ExtJS中的各種liveGrid實現來了解如何實現此目的,因為這基本上就是您要創建的。
這是我使用過的最穩定,最全面的livegrid: http : //www.ext-livegrid.com/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.