cnq77f

Jan 05 2009

Params in Ext.data.Store not passed to the server

Filed under: xn--cnq77f.com

  • I noticed that my Ext.data.Store doesn't send the value of params (nor baseParams, for that matter) to the server when i call getStore().load(). The call itself goes to the server, of course, but the Request.Form is empty!

    I fixed the issue by sending in {params: 'bzzzz'} as a parameter to the load() method. However, i'd love to know why it didn't worked the expected way.

    I also tried to create proxy. That went equivalently fuilure-ish as well. I'm unsure what proxy is good for but that's a story for another thread, coming soon to a forum near you.


  • Got it. What happaned to the good, old params, then? I'd prefer to specify it in the definition of my Ext.data.store object instead of specifying it in the load() function.


  • None of these worked as expected. Form property on the server was empty.
    store: new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
    url: 'TransferData.aspx?transactionType=download',
    params: 'bzzz',
    method: 'POST'
    }),
    reader: new Ext.data.XmlReader({record: 'row'},
    [{name: 'organizationNumber', mapping: 'OrganizationNumber'}])
    })

    store: new Ext.data.Store({
    url: 'TransferData.aspx?transactionType=download',
    baseParams: 'bzzz',
    reader: new Ext.data.XmlReader({record: 'row'},
    [{name: 'organizationNumber', mapping: 'OrganizationNumber'}])
    })

    store: new Ext.data.Store({
    url: 'TransferData.aspx?transactionType=download',
    params: 'bzzz',
    reader: new Ext.data.XmlReader({record: 'row'},
    [{name: 'organizationNumber', mapping: 'OrganizationNumber'}])
    })


  • Well, that's matter of taste and sometimes of habits. What's natural for one developer is not for another. The best is to stick with API docs.


  • You need to give the bzzz variable to be posted a value. Try this:

    baseParams: {bzzz: '123'}


  • Maybe I'm confused by your confusion.

    Ext.data.Store has a configuration property baseParams (http://extjs.com/deploy/dev/docs/?class=Ext.data.Store&member=baseParams). Whatever you specify there is sent with all load requests (unless you change it programmatically).

    store: new Ext.data.Store({
    url: 'TransferData.aspx?transactionType=download',
    baseParams: {
    bzzz: 'someValue'
    }
    reader: new Ext.data.XmlReader(
    {record: 'row'},
    [
    {name: 'organizationNumber', mapping: 'OrganizationNumber'}
    ]
    )
    })

    Every time the store is loaded a parameter will be sent (bzzz: 'someValue').

    Now, Ext.data.Store has a method called load (http://extjs.com/deploy/dev/docs/?class=Ext.data.Store&member=load)(someObject). The API says one of the properties you can specify for someObject is params (An object containing properties to pass as HTTP parameters to a remote data source).

    So, if you want to load a store at some point in time with some parameters only for that particular store load then you'd do:

    store.load({
    params:{
    start:0,
    limit:6,
    someParam: 'someParamValue'
    }
    });


  • Of course! :)


  • Adding baseParams to your Ext.data.Store configuration should ensure that these additional params are posted with every load of the store. If you could post some code as to what you were trying, we could help you troubleshoot what was going wrong.


  • I didn't mean they were. I ment that, in my opinion, it felt more natural to have them in params. YMMV widely, of course.


  • Got it. What happaned to the good, old params, then? I'd prefer to specify it in the definition of my Ext.data.store object instead of specifying it in the load() function.
    AFAIK, there were never params as store's property, they were always an argument to load method. Anyway, my memory may have failed...







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Params in Ext.data.Store not passed to the server , Please add it free.
    edit