1. #1
    Sencha User
    Join Date
    Jan 2012
    Location
    Atlanta, Georgia
    Posts
    40
    Vote Rating
    2
    mbritton is on a distinguished road

      0  

    Default Adding Parameters to the PagingToolbar

    Adding Parameters to the PagingToolbar


    My PagingToolBar isn't sending the parameters I specify in my store.

    When my application loads, I'm fetching records from my services.

    Code:
    PostProxy.prototype.getPosts = function() {
        Ext.create('Ext.data.Store', {
            model:'Post',
            pageSize:50,
            autoLoad:false,
            storeId:'PostStore',
            baseParams:{ getall:true, profile:true, blogid:3 },
          
        });
       
       var store = Ext.StoreMgr.lookup('PostStore');
       store.on({'datachanged':this.onDataChanged});
       store.on({'load':this.onPostsRetrieved});
       
        // These parameters are needed on every GET request
        store.load({
            params : {
                start : 0,
                limit : 50,
                getall:true,
                profile:true,
                blogid:3
            }
        });   
    };
    A notification is sent to my GridPanel when the data load. If my grid hasn't been created, it's created:

    Code:
    buildBlogPosts : function() {
        console.log('buildBlogPosts:::::');
        var store = Ext.StoreMgr.lookup('PostStore'); // Store has correct baseParams
    
    
        var gp = Ext.getCmp('postPanel');
        if (!gp) {
            
            var gp = Ext.create('Ext.grid.Panel', {
                id:'postPanel',
                store : store,
                autoHeight : true,
                layout: {
                    type:'fit',
                    align:'stretch'
                },
                viewConfig : {
                    trackOver : false,
                    stripeRows : false,
                },
                listeners : {
                    itemclick : function(grid, item) {
                        Ext.getCmp('east').PostSelected.dispatch(item);
                    }
                },
                columns : [{
                    header : 'Title',
                    dataIndex : 'entry_title',
                    flex : 1
                }],
                bbar : Ext.create('Ext.PagingToolbar', {
                    id:'paginator',
                    store : store, // same store grid is using
                    displayInfo : true
                })
            });
            
            Ext.getCmp('cards').add(gp);
            
            // Is this where I intercept the GET and add the extra parameters??
            Ext.getCmp('paginator').on('beforechange', function(itm) {
                console.log('BEFORECHANGE');
                console.dir(itm);
            });
            
            Ext.getCmp('cards').getLayout().setActiveItem(1);
            
        }
    }
    When I click the 'next' button on PagingToolBar and a new request is sent, I don't see my params in the querystring. I just see the start, page and limit variables.

    Why aren't my params being sent when the page changes?

    Thanks in advance!

  2. #2
    Sencha User carol.ext's Avatar
    Join Date
    Jun 2007
    Location
    Littleton, Colorado, USA
    Posts
    680
    Vote Rating
    22
    carol.ext will become famous soon enough carol.ext will become famous soon enough

      0  

    Default


    Have you tried using extraParams on the proxy?

    Not sure what proxy you are using, but here is link to the Ajax proxy

  3. #3
    Sencha User
    Join Date
    Jan 2012
    Location
    Atlanta, Georgia
    Posts
    40
    Vote Rating
    2
    mbritton is on a distinguished road

      1  

    Default


    I see, you have to add them to the proxy. Thanks!

    [Solved]
    Code:
    
    store.getProxy().extraParams.getall = true;
    store.getProxy().extraParams.profile = true;
    store.getProxy().extraParams.blogid = 1;
    If you want to change the params each time, you'd have to use:

    Code:
    store.on('beforechange', function() {
        store.getProxy().extraParams.getall = <SOMEVAL>;
        store.getProxy().extraParams.profile = <SOMEVAL>;
        store.getProxy().extraParams.blogid = <SOMEVAL>;     
    });

Thread Participants: 1

Tags for this Thread