1. #1
    Ext User
    Join Date
    Jan 2009
    Posts
    543
    Vote Rating
    0
    dbassett74 is on a distinguished road

      0  

    Default How to specify jsonData as option in store.load()?

    How to specify jsonData as option in store.load()?


    It seems that the JsonStore.load() does not accept jsonData as an option. I can't use the params because it doesn't send it as json formatted. Here is the code I'm trying to use, but it doesn't pass the jsonData to the web service. When initially setting the jsonData for the store, it works, but I need to be able to change the jsonData at run time based on user actions.

    Code:
    var options = {
       jsonData: {
          projectNo: '0120'
       }
    };
    grid.store.load(options);
    Any help would be appreciated.

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    2
    tryanDLS is on a distinguished road

      0  

    Default


    loadData instead of load

  3. #3
    Ext User
    Join Date
    Jan 2009
    Posts
    543
    Vote Rating
    0
    dbassett74 is on a distinguished road

      0  

    Default


    Don't think that's what I'm looking for. Perhaps I didn't fully explain how I was using the store. I am using a proxy. Here is how the store is defined:

    Code:
        var store = new Ext.data.JsonStore({
        autoLoad: false
        , proxy: new Ext.data.HttpProxy({
            method: 'POST'
            , jsonData: {id: '1'}   <-------  I need to change this at any time
            , url: 'process.asmx/getFiles'
            , headers: { 'Content-Type': 'application/json;charset=utf-8'}
         })
          , root: 'd' //the root node of the json object - always 'd' from asp.net web service
          , id: 'id' //the record id
          , fields: ['id', 'name']
       });
    So how would I reload the above store and specify what the jsonData should be?

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    2
    tryanDLS is on a distinguished road

      0  

    Default


    Your question doesn't make sense. HttpProxy doesn't have a jsonData config. The data comes from the result of the proxy's request - you can't inject data into it.

    Are you trying to pass additional parms with the request? That's done via params/baseParams on the store

  5. #5
    Ext User
    Join Date
    Jan 2009
    Posts
    543
    Vote Rating
    0
    dbassett74 is on a distinguished road

      0  

    Default


    I use it in several places to pass jsonData to the web service. It definitely works. And according to the documentation for Connection, which is what HttpProxy uses, jsonData IS a valid parameter.

  6. #6
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    What about declaration:
    Code:
    store = new Ext.data.JsonStore({
        autoLoad: false,
        proxy: new Ext.data.HttpProxy({
            method: 'POST',
            jsonData: {
                id: '1'
            },//
            url: 'test.php',
            headers: {
                'Content-Type': 'application/json;charset=utf-8'
            }
        }),
        root: 'd', //the root node of the json object
        id: 'id', //the record id
        fields: ['id', 'name']
    });
    Initial load test:
    Code:
    store.load();
    modify proxy's jsonData property
    Code:
    store.proxy.conn.jsonData = {
        foo: 'bar'
    }
    Another load test:
    Code:
    store.load();

  7. #7
    Ext User
    Join Date
    Jan 2009
    Posts
    543
    Vote Rating
    0
    dbassett74 is on a distinguished road

      0  

    Default


    Yep, that did the trick. Thanks!

  8. #8
    Ext JS Premium Member christocracy's Avatar
    Join Date
    Oct 2006
    Location
    Montreal
    Posts
    380
    Vote Rating
    0
    christocracy is on a distinguished road

      0  

    Default


    Quote Originally Posted by dbassett74 View Post
    It seems that the JsonStore.load() does not accept jsonData as an option.
    I know exactly what you mean. When adding REST support, I added support for using the jsonData param of Ext.Ajax#request.

    Here's a little block from HttpProxy#doRequest
    Code:
    if (typeof(params[reader.meta.root]) === 'object') {
        o.jsonData = params;
    } else if (params.xmlData) {
        o.xmlData = params.xmlData;
    } else {
        o.params = params || {};
    }
    I just added the support for xmlData yesterday; that's related to some work I'm doing to support XmlWriter which hasn't yet been committed.

    The bit in red though, I'm thinking of changing to params.jsonData for consistency (that data is appended to the params in Ext.data.DataWriter). Therefore, I think it's valid to expect to be able to add jsonData as in the code snippet you posted.

    Code:
    var options = {
       jsonData: {
          projectNo: '0120'
       }
    };
    Currently though, I think you could trick the HttpProxy into sending jsonData by simply defining an object {} in the params using a key matching your JsonReader's "root" config property.

    eg:

    Code:
    var reader = new Ext.data.JsonReader({
        root: 'my_data'
    });
    var hproxy = new Ext.data.HttpProxy({
        url: 'my_url',
        listeners: {
            beforeload: function(proxy, options) {
                options.params.my_data = {
                    projectNo : '0120'
                }
            }
        }
    /**
    * @author Chris Scott
    * @business www.transistorsoft.com
    * @rate $120USD / hr; training $500USD / day / developer (5 dev min)
    *
    * @SenchaDevs http://senchadevs.com/developers/transistor-software
    * @twitter http://twitter.com/#!/christocracy
    * @github https://github.com/christocracy
    */

  9. #9
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    Is there likelihood that someone would send jsonData and xmlData?

    I posted separately about this about the various reader files which store an arrayData, jsonData, or xmlData property depending on the reader type.

    My contention is why all the renaming? Why not just have the reader store readData? That way the code can be more loosely coupled and just refer to readData when it wants to access that property regardless of what the reader type was. (granted each one is unique to it's data format, but I don't see the need to change the property name because of that ... we don't have xml_url to configure an XML store do we?)

    Same goes for this particular thread (perhaps?). Do we want to reconfigure the store or proxy to have a unique property of jsonData, xmlData, params, or baseParams? Or do we really just care to say hey, these are my "params" I want sent to the server and I want to send them in format:'foo' and with method:'POST' or 'GET'.

  10. #10
    Ext JS Premium Member christocracy's Avatar
    Join Date
    Oct 2006
    Location
    Montreal
    Posts
    380
    Vote Rating
    0
    christocracy is on a distinguished road

      0  

    Default


    My contention is why all the renaming?
    Yes, I think you're right MJ. As I expand into XmlWriter, it's becoming more clear.
    /**
    * @author Chris Scott
    * @business www.transistorsoft.com
    * @rate $120USD / hr; training $500USD / day / developer (5 dev min)
    *
    * @SenchaDevs http://senchadevs.com/developers/transistor-software
    * @twitter http://twitter.com/#!/christocracy
    * @github https://github.com/christocracy
    */

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar