Results 1 to 5 of 5

Thread: HowTo pass an id to proxy in data.store

  1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    58
    Answers
    4
    Vote Rating
    1
      0  

    Default Answered: HowTo pass an id to proxy in data.store

    Hi

    I was wondering how I can pass an id to the ajax proxy

    Code:
                var storeWebpage = new Ext.data.Store({
                model: 'ListItem1',
                autoLoad: false,
                //remoteFilter: true,
                //sortOnFilter: true,
                //sorters: [{property : 'lastname', direction: 'ASC'}],
                pageSize: 1,
                clearOnPageLoad: false,
    listeners: {
    load : function(){
    
    
    console.log(this.sid);
    }
    },
                proxy: {
                    type: 'ajax',
                    url: 'http://www.hws-koeriers.nl/hws/flex/user.php?sid=' + this.sid,
    
    
                    reader: {
                        //root: 'profile',
                        type: 'json'
                    },    
    
    
                    extraParams: {
                        rpp: 1,
                        suppress_response_codes: true
                        }
                }
            });
    I tested the id ouside the proxy and there the console.log shows my id but within the proxy it's undefined

    test code

    listeners: {
    load : function(){


    console.log(this.sid);
    }
    },

    I am passing the variable from an onItemDisclosure

    Code:
    onItemDisclosure: {
                    scope: 'this',
                    handler: function(record, btn, index) {
                        //alert('Disclose more info for ' + record.get('id'));
    
    
    		storeWebpage.sid = record.get('id');
    
    
    		panel.setActiveItem(3, {type: 'slide', direction: 'right', params: { sid1: record.get('name')}});
    
    
    		storeWebpage.load();
                    }
                },
    thanks in advance

  2. If you want it in your storeWebpage.load(); call you can add it as a param:

    Code:
    storeWebpage.load({
        params : {
            id : 'foo'
        }
    });
    Or you can apply it to the extraParams if you need it to stick around (like when you refresh or load a new page):

    Code:
    storeWebpage.proxy.extraParams.id = 'foo';

  3. #2
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,159
    Answers
    93
    Vote Rating
    7
      0  

    Default

    Sorry, could you explain your issue a little more? I'm not sure where you want an ID and why.
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

  4. #3
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,422
    Answers
    3901
    Vote Rating
    1271
      0  

    Default

    If you want it in your storeWebpage.load(); call you can add it as a param:

    Code:
    storeWebpage.load({
        params : {
            id : 'foo'
        }
    });
    Or you can apply it to the extraParams if you need it to stick around (like when you refresh or load a new page):

    Code:
    storeWebpage.proxy.extraParams.id = 'foo';
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #4
    Sencha User
    Join Date
    Jul 2011
    Posts
    58
    Answers
    4
    Vote Rating
    1
      0  

    Default

    Thank you verry much

    that was just what I was looking for ..

  6. #5
    Touch Premium Member
    Join Date
    Nov 2011
    Posts
    37
    Vote Rating
    0
      0  

    Default

    Is there any way to prevent the proxy from sending the other parameters (i.e. _dc, start, limit) on a stores load() call? My backend is expecting to use every parameter sent back for filtering purposes. For the time being I've set it up to just ignore those listed above, but I've just run into a situation where Sencha is sending sending a filter parameter, and it seems like it would just be easier to have all the parameters (besides those I specify) left out entirely. Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •