【问题标题】:Extjs paging toolbar with grid panel not working带有网格面板的 Extjs 分页工具栏不起作用
【发布时间】:2012-11-08 18:03:04
【问题描述】:

我在 extjs 中有以下分页代码...即使我将其设置为每页 5 条记录,它仍然显示 6...并且第 1 页(共 2 页)不显示“1”...我有问题使用来自 sql Click here to go that Thread....的数据,所以我决定尝试使用内存存储...但我仍然无法正确分页....有什么帮助吗?

    constructor: function () {
    this.callParent(arguments);
    var store = Ext.create('Ext.data.Store', {
        pageSize: 5,
        storeId: 'simpsonsStore',
        fields: ['name', 'email', 'phone'],
        data: {
            'totalCount': "6",
            'items': [{
                'name': 'Lisa',
                "email": "lisa@simpsons.com",
                "phone": "555-111-1224"
            }, {
                'name': 'Bart',
                "email": "bart@simpsons.com",
                "phone": "555-222-1234"
            }, {
                'name': 'Homer',
                "email": "home@simpsons.com",
                "phone": "555-222-1244"
            }, {
                'name': 'Marge',
                "email": "marge@simpsons.com",
                "phone": "555-222-1254"
            }, {
                'name': '29',
                "email": "marge@simpsons.com",
                "phone": "555-222-1254"
            }, {
                'name': '30',
                "email": "marge@simpsons.com",
                "phone": "555-222-1254"
        }]
    },
    proxy: {
        type: 'memory',
        reader: {
            type: 'json',
            root: 'items',
            totalProperty: 'totalCount'
        }
    }
});

this.grid = Ext.create('Ext.grid.Panel', {
    title: 'Simpsons',
    disableSelection: true,
    loadMask: true,
    stripeRows: true,
    trackover: true,
    renderTo: Ext.getBody(),

    store: store,
    columns: [{
        text: 'Name',
        dataIndex: 'name'
    }, {
        text: 'Email',
        dataIndex: 'email'
    }, {
        text: 'Phone',
        dataIndex: 'phone'
    }],


    bbar: Ext.create('Ext.PagingToolbar', {
        store: store,
        displayInfo: true,
        displayMsg: 'Displaying Surveys {0} - {1} of {2}',
        emptyMsg: "No Surveys to display"
    })


});
grid.loadPage(1);
}

} });

【问题讨论】:

  • 尝试为数据添加一个 id 属性。

标签: gridview extjs paging


【解决方案1】:

内存代理不适用于常规分页机制。您需要一个特殊的用户扩展类:http://docs.sencha.com/ext-js/4-1/#!/api/Ext.toolbar.Paging 向下滚动到“使用本地数据分页”部分。

【讨论】:

  • 谢谢 dbrin... 我知道我必须使用本地数据寻找分页,但假设我使用静态数据会有所不同。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-04
  • 1970-01-01
  • 1970-01-01
  • 2015-04-23
相关资源
最近更新 更多