设置页面大小Sencha触摸 [英] Set page size Sencha touch

查看:132
本文介绍了设置页面大小Sencha触摸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试设置一个页面大小,以便我的应用程序运行得更快。我正在读取一个巨大的xml文件(数千行),我想使用ListPaging插件一次只加载一个页面。

I've been trying to set a page size so that my app runs faster. I'm reading from a huge xml file (thousands of rows) and I want to use the ListPaging plugin to load only one 'page' at a time.

这是我的列表:

                                            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数据,但这次只是将它连接到整个列表。

However when I run this, all I get is 'loading more...' text at the bottom of the entire list (not 15 items down), and then it only loads the same xml data again, but this time just concatenates it to the end of the entire 'list'.

如何设置页面大小,以便每个页面只显示15个左右的项目,然后滚动到列表的底部(这是15个项目长)我得到接下来的15个项目连接到最后15个项目,共计30个项目显示..等等。

How do I set the page size so that I only get 15 or so items to display per 'page', then when I scroll to the bottom of the list (that's 15 items long) I get the next 15 items concatenated to the last 15 items to make a total of 30 items display.. and so forth.

使用Sencha Touch 2.4。 1

Using Sencha Touch 2.4.1

更新:
这是配置:

UPDATE: Here is the config:

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?
    }
}

}


推荐答案

从您提供的场景中,似乎您的网络服务不符合Sencha的 ListPaging 插件。
pageSize store config

From the scenario which you have provided, it seems your web-services are not according to Sencha's ListPaging plugin. pageSize is being correctly used by you in store config .

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

您的API响应应具有以下属性,以支持 ListPaging

Your API response should have following properties to support ListPaging:


  1. 总计:此字段/您的API将随附财产。有了这个价值,插件决定应用程序是否已经到达列表的末尾。

  1. total : This field/property will be coming with your API. With the value of this, the plugin decides whether the application has reached end of the list or not.

开始:这是由插件在标头中发送的,远程代理将会知道从哪个索引位置将提取数据。

start: This is send by the plugin in the Headers and remote proxy will get to know that from which index position the data fetching will be initiated.

限制:这只是你的 pageSize 。它也由插件在头文件中发送,远程代理将知道应该从开始 index。

limit: This is nothing but your pageSize. It is also send by the plugin in the Headers and remote proxy will get to know that how many numbers of data data it should fetch fro the start index.

所以检查你的api响应是否有总共开始限制 params。如果它在那里,只需将该阅读器添加到您的代理中:

So check with your api response if it is having total, start and limit params or not. If it is there, just add this reader in your proxy:

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

你的问题会解决。
随意要求任何其他澄清。

And you problem will be resolved. Feel free to ask for any other clarification.

---------------------- ----------------的修改 -------------------------- ---------------------

--------------------------------------EDIT-----------------------------------------------

'总计','开始'和'限制'应该进入api响应以支持列表。您不必在代理中明确地发送它(正如您在编辑部分发送)

'total', 'start' and 'limit' should come in the api response to support listpaging. You don't have to send it explicitly in your proxy(As you are sending in edited section)

这篇关于设置页面大小Sencha触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆