2012-12-04 63 views
2

我有一个组合框,商店通过远程从服务器获取数据。我的问题是我的分页不起作用。这里是我的代码片段:EXTJS Remote Combobox

Ext.define('EmployeeModel', { 
    extend: 'Ext.data.Model', 
    fields: [ 
     {name:'id', type:'int'}, 
     {name:'fullname', type:'string'} 
    ] 
    }); 

    // remote store 
    var employeeStore= new Ext.data.Store(
    { 
    model: 'EmployeeModel', 
    pageSize: 10, 
    proxy: { 
     url: '/schedule/home/EmployeeList', 
     params: { 
      'active_id': params 
     }, 
     type: 'ajax', 
     autoLoad: true, 
     reader: 
     { 
      root: 'data', 
      totalProperty: 'total', 
      id: 'id', 
      type: 'json' 
     }, 
     simpleSortMode: true 
    } 
    }); 



    this.employeeBox = new Ext.form.ComboBox(
    { 
    store: employeeStore, 
    displayField: 'fullname', 
    valueField: 'id', 
    typeAhead: false, 
    loadingText: 'Searching...', 
    triggerAction: 'all', 
    hiddenName: 'employee', 
    name: 'Employee Name', 
    fieldLabel: 'Employee', 
    selectOnFocus: true, 
    allowBlank: false, 
    anchor: '98%', 
    width: 370, 
    enableKeyEvents: true, 
    pageSize: true, 
    minListWidth: 220, 
    minChars: 2, 
    labelWidth: this.labelWidth, 
    resizable: false 
    }); 

我不知道所缺乏的,但正如我已经通过我复制并测试所有互联网搜索远,它仍然无法正常工作。

回答

1

如果您有远程存储,分页也应该是远程的。 pageSize只是发送到服务器的参数,您应该在那里处理分页。除了pageSize,您还会看到诸如startlimit之类的参数。

你可以在这里看到例如:http://docs.sencha.com/ext-js/4-1/#!/example/form/forum-search.html 退房萤火虫或类似的东西的要求,你会看到网址如下:http://www.sencha.com/forum/topics-remote.php?_dc=1354611968514&query=form&page=2&start=10&limit=10&callback=Ext.data.JsonP.callback3

如果你想对客户端分页,您可以创建本地存储和预紧数据通过自定义AJAX请求。

+0

正如我所观察到的,它加载了结果但未分页。在我上面提到的URL中,它来自一个php文件,它从查询中返回一个“json_encode”数组。其中我的查询是每个按键获取角色。有什么我应该在我的查询?顺便说一句我使用symfony 1.4 – oneofakind

+0

'http:// www.sencha.com/forum/topics-remote.php'是绝对分页 - 请参阅[此链接](http://www.picamatic.com/view/8854690_Untitled/ )如果你不相信:)我不知道交响乐,所以我不会告诉你如何去做。通常在SQL查询中进行远程分页。 – Krzysztof