-->

设置页面大小煎茶触摸(Set page size Sencha touch)

2019-10-22 08:57发布

我一直在试图让我的应用程序运行速度更快设置页面大小。 我是从一个巨大的XML文件读取(几千行),我想使用ListPaging插件在同一时间只加载一个页面“。

这里是我的清单:

                                            xtype : 'list',          
                                            plugins: {
                                                xclass: 'Ext.plugin.ListPaging',
                                                autoPaging: true,
                                                loadMoreText : 'Loading more...',
                                                noMoreRecordsText : 'loaded'
                                            },
                                            store : 'mainStore',
                                            height : '100%',
                                            layout : 'fit',
                                            id: 'myList',
                                            flex : 5,
                                            itemTpl : "foo"

这里是我的商店:

config: {
model : 'myApp.model.foo',
storeId: 'mainStore',
autoLoad: true,
//currentPage: 1,
//buffered: true,
pageSize: 15,

proxy : {
    type : "ajax",
    url : 'resources/images/data/fooBar.xml',
    startParam: 'offset',
    reader : {
        type : "xml",
        rootProperty : 'foo',
        record : 'bar'
    }
}

}

然而,当我运行它,我得到的是“加载更多...”在整个列表(而不是15项下)的底部文本,然后它只是再次加载相同的XML数据,但是这一次只是它加到整个名单“的结束。

如何设置页面大小,这样我只得到15名左右的项目每“页”显示,然后当我滚动到列表的底部(这是15个条目),我得到下一个15个项目串接到最后15项目从一共有30个项目显示..等等。

使用Sencha触摸2.4.1

更新:这里是配置:

config: {
model : 'c17App.model.approaches',
storeId: 'mainStore',
autoLoad: true,
pageSize: 15,

proxy : {
    type : "ajax",
    url : 'resources/images/data/approach_all.xml',
    total:  17,
    start: 1,
    limit: 15,
    reader : {
        type : "xml",
        rootProperty : 'approaches',
        record : 'approach',
        totalProperty: 'total'//maybe needs to be a number?
    }
}

}

Answer 1:

从您提供的情况下,它的网络服务,不按煎茶的似乎ListPaging插件。 pageSize是在正确使用你所store config

config: {
    pageSize: 15,
    ......
}

你的API响应应该具有以下特性支持ListPaging

  1. total :这个字段/属性将与您的API到来。 随着这种价值,插件决定申请是否已达到列表或没有结束。

  2. start :这是由插件在发送Headers和远程代理会了解,从哪个索引位置的数据取将被启动。

  3. limit :这只是你pageSize 。 它还通过在插件发送Headers和远程代理会了解它应该是多少数据资料的数字来回抓取start索引。

因此,与您的API响应检查是否有它totalstartlimit PARAMS与否。 如果它是存在的,只是添加此读者您的代理:

reader: {
    type: 'xml', // 'json' if the api is giving response in json format
    rootProperty: 'xyz', // Depends on your api response.
    totalProperty: 'total'
}

你的问题将得到解决。 随意问任何其他澄清。

-------------------------------------- 编辑 ----------- ------------------------------------

total ”,“ start ”和“ limit ”应该来在API响应支持listpaging。 你不必在你的代理明确地把它(正如你在编辑的部分发送)



文章来源: Set page size Sencha touch