导航

基于slick grid做infinite scroll(2)

Posted on 2013-07-23 11:24  zhustar  阅读(246)  评论(0编辑  收藏  举报

看来我这个标题得改一改了,

基本上不需要我操作slick grid了,我们用了MAAS team的maas grid,

他们对scroll的定义是virtual scroll with dynamic data set,

我要做的是在data source plugin 中对数据的获取做配置。

 this.read = function (options, success) {
                    dataConfig.data(options).then(function (entityCollections) {
                        var result = {
                            items: [],
                            meta: {
                                total: 0
                            }
                        };

                        angular.forEach(entityCollections, function (entityCollection) {
                            result.items = _.union(result.items, entityCollection.entities);
                            result.meta.total+=entityCollection.totalCount;
                        });

                        success(result);
                    });
                };

将options传入到dataConfig.data方法中,该options对应于data-source-svc的queryOptions.

在tree-module-children-grid-controller的getChildrenWithEntityType中将startIndex:options.skip + 1添加到configuration中。

 

skip的计算是为了保证view port 在page 中间,基本上=from -(pageSize/2-viewport/2),他的最小值是0,但是alm 的entities是从1开始计数,

所以需要再加上1.

 

在entity-factory里params['start-index'] =  configuration.startIndex;

将start-index作为查询rest的查询条件。

 

基本上这样就差不多了。

赚工资很容易有没有,哈哈!