0
votes

I can´t get my grid to work with paging. Here is my code (this code is executed inside the controller.js after the user types some information in a textField control):

    var store = Ext.create('App.store.vo.Posts', {
        autoLoad: {
            params: {
                query: textTyped,
                start: 0,
                limit: 10
            },
            callback: function (regs) {
                me.getGrid().reconfigure(store);
                me.getGrid().down('pagingtoolbar').bindStore(store);
            }
        }
    });

and this is my store code:

Ext.define('App.store.vo.Posts', {
    extend: 'Ext.data.Store',

    model: 'App.model.vo.Post',
    autoLoad: true,
    autoSync: false
});

The grid populates with data correctly, but the paging is disabled.

UPDATE:

and the Post model:

Ext.define('App.model.vo.Post', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'id', type: 'auto'},
        {name: 'text', type: 'auto'}        
    ],
    idProperty: 'id',
    proxy: {
        type: 'rest',
        url : '/posts',
        format: 'json',
        reader: {
            root: 'data',
            successProperty: 'success',
            totalProperty: 'total'
        },
        writer: {
            // wrap post params for Rails
            getRecordData: function(record) {
                return { post: record.data };
            }
        }
    }
});
2
Have you checked request header in a debugger (firebug)?leaf
Yes, the grid is filled with the first page. Only pagination is not working.Beetlejuice

2 Answers

1
votes

I get this to work this way:

    //set the 'query' param before load 
    var store = Ext.create('App.store.vo.Posts', {
        listeners: {
            beforeload: function(s,op, ot) {
                op.params = {
                    query: filtro
                }
            }
        }
    });


    store.load({
        callback: function (regs) {
            if (store.data.length > 0) {
                me.getGrid().getView().focus(true, 200);
                me.getGrid().getView().select(0);
            }
        },
        params: {
            query: filtro,
            field: campo,
            start: 0
        }
    });
    me.getGrid().reconfigure(store);
    me.getGrid().down('pagingtoolbar').bindStore(store);
0
votes

You should try this (see Ext.data.Operation) :

autoLoad: {
    start: 0,
    limit: 10,
    params: { ... },
    callback: function () { ... }
}

Update

I'm wondering if pageSize is required to make pagination work. Default value is set to 25, maybe you should set this property according to your desired page size :

var store = Ext.create('App.store.vo.Posts', {
    pageSize: 10