组合框分页工具栏不响应页面大小 [英] Combobox paging toolbar doesn't respond to page size

查看:49
本文介绍了组合框分页工具栏不响应页面大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在从数据库中选择项目的组合框遇到了一些问题. 由于加载了100多个项目,因此我使用组合框底部的分页工具栏. 现在,如果页面大小设置为5或50,则分页工具栏将显示第1页(共20页)或第1页(共2页),具体取决于页面大小,但是组合框显示所有100个项目,只需将它们复制到下一页,就像根本没有设置页面大小一样. 我尝试了几件事,但似乎没有任何效果. 怎么了?

I'm having some problems with combobox for selecting items from database. Since more than 100 items are loaded, I use paging toolbar at bottom of combobox. Now if pages size is set to 5 or 50, the paging toolbar shows page 1 of 20 or 1 of 2 depending on pagesize, but combobox shows all 100 items, and just copy them to next page like page size is not set at all. I tried several thing but nothing seems to make it work. What's wrong?

{
    xtype: 'combobox',          
    queryMode: 'local',
    valueField: 'id',
    fieldLabel: 'Description SKU',
    name: 'id_fk',
    pageSize: 5,                
    width: 400,
    padding: 5,
    store: Ext.create('Ext.data.Store',
            {
                fields: ['id','key item','description'],
                autoLoad: true, 
                pageSize: 5,                        
                proxy:
                {
                    type: 'ajax',
                    url: 'items/load',
                    reader:
                    {
                        type: 'json',
                        root: 'data'
                    }
                }
            }),
    tpl: Ext.create('Ext.XTemplate',
            '<tpl for=".">',
                '<div class="x-boundlist-item">{key item} - {description}</div>',
            '</tpl>'),

    displayTpl: Ext.create('Ext.XTemplate',
                            '<tpl for=".">',
                                '{key item} - {description}',
                            '</tpl>'
                            )
}

推荐答案

在提出加载商店的请求时,它将传递一个值为5的pageSize查询参数.

When the request is made to load the store, it will pass a pageSize query parameter with value 5.

但是,由服务器端服务决定返回结果时是否考虑此参数.

However, it is up to your server-side services to take this parameter into account when returning results.

这是分页组合框的示例:

Here's an example of paging combobox: http://docs.sencha.com/extjs/4.1.3/#!/example/form/forum-search.html

如果在Web开发控制台上打开网络"选项卡,则将看到正在触发的请求,您可以查看查询参数.您可以根据需要发送其他邮件,但这对于基本的分页应该绰绰有余.

If you open the network tab on your web development console, you will see the request being fired and you can look at the query parameters. You can send others as necessary, but this should be more than enough for basic paging.

以下是发送的查询参数:

The following are the query parameters sent:

限制-通过"pageSize"参数设置(默认值为25)

limit - set by the "pageSize" parameter (default of 25)

开始-要返回的第一条记录(从0开始,并使用工具栏上的上一页/下一页按钮增加pageSize)

start - the first record to be returned (starts at 0 and is incremented by pageSize using the prev/next buttons on the toolbar)

page-我们所在的页面(从1开始,使用工具栏上的prev/next按钮递减/递增1)

page - the page we are on (starts at 1 and is decremented/incremented by 1 using the prev/next buttons on the toolbar)

query-组合框中的文本.

query - the text in the combobox.

您还应该在服务器的响应中返回"totalProperty",其中包含结果总数.这将适当地更新工具栏(例如,您在y的第x页).默认情况下,totalProperty预期为总计".在查看提供的示例中的代码时,您可以看到这一点.

EDIT 2: You should also be returning a "totalProperty" in your response from your server which has the total number of results. This will update the toolbar appropriately (e.g you are on page x of y). By default, the totalProperty expected is "total". You can see this when you look at the code in the example provided.

这篇关于组合框分页工具栏不响应页面大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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