Extjs paging toolbar with grid panel not working

只愿长相守 提交于 2019-12-11 14:04:58

问题


I have the below code for paging in extjs... Even though I set it as 5 records per page, it still shows 6... and page 1 of 2 does not show "1"... I had problem with data from sql Click here to go that Thread.... so I decided to try out with memory store... but I still don't get the paging right.... any help?

    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);
}

} });


回答1:


Memory proxy wont work with a regular paging mechanics. You need a special user extension classes: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.toolbar.Paging Scroll down to "Paging with Local Data" section.



来源:https://stackoverflow.com/questions/13295005/extjs-paging-toolbar-with-grid-panel-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!