[英]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.