Hybrid View

  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    72
    Answers
    3
    Vote Rating
    0
    kalor is on a distinguished road

      0  

    Default Unanswered: Interpreting results of listener

    Unanswered: Interpreting results of listener


    Hi guys,

    I have a web service that (using some test settings) returns this JSON if you browse to it:
    Code:
    {"ErrorMessage":"You are not authorised","ResponseTime":"\/Date(1321447985287)\/","StatusCode":401,"Success":false}
    I then try to read it from this code. The server is returning the values above, the load event is being fired, but I don't know how to make any sense of the values (I've called them Field1 to Field4 because I can't even determine which is which!).

    I want the alert to read the values, eg "response message: You are not authorised, 17/11/2011 09:25:00, 401, false ".

    I thought I'd be able to just use the alert below, or use Field1.getValue(), or Field1.getString(), or new string(Field1), or JSON.Parse(Field1) or SOMETHING. All I get is [object Object]. How do I access the object's data??

    if I try
    Code:
    alert('response message:' + Ext.StoreMgr.get("declineResult").getAt(0).ErrorMessage);
    I get

    Ext.StoreMgr.get("declineResult").getAt(0)' [undefined] is not an object.

    Code:
    var declineResult =  new Ext.regStore('declineResult', 
    {
        model: 'BaseResponse',
            proxy : {
            type : 'ajax',
            dataType: "json",
            url :  App.BaseURL + '/SetJobResponse/' + options.jobId + '/' + STCID +'/1/' + device.uuid,
            reader: new Ext.data.JsonReader ({
               type: 'json'
                })
        },
            listeners: 
            {
                load: function(Field1, Field2, Field3, Field4)
                    {
                        alert('response message:' + Field1 + ',' + Field2 + ',' + Field3 + ',' + Field4);                    
                    }
            }
    });
    
    Ext.StoreMgr.get("declineResult").load();
    EDIT: this thread says that my load event definition should be just function():

    http://www.sencha.com/forum/showthread.php?112169-Event-on-Store-to-trigger-after-data-is-fully-loaded

    Yet squillions of other threads say it's function(store,records,options). Which is it?

    I can't find anything about it in the 2.0 docs or the 1.1 docs. There was something in the ExtJS docs, but apparently I'm not supposed to mix extjs and sencha code. Whenever I try to find basic API information and which method/property/event to use, I end up getting pushed to glossy irrelevant screencasts.

    The reputation of this thing is well deserved. The learning curve is like being placed at the controls of a 747 in flight and being handed the instructions to a 767 model kit.

  2. #2
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,361
    Answers
    102
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    It's: function(store,records,options)

    The load event listener should be well documented. That said, you're posting in the Sencha Touch 2 forums for sencha touch 1 code.

  3. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    72
    Answers
    3
    Vote Rating
    0
    kalor is on a distinguished road

      0  

    Default


    For those following, regStore (http://docs.sencha.com/touch/1-1/#!/...ethod-regStore) doesn't mention the load event because it's kept at Ext.data.store (http://docs.sencha.com/touch/1-1/#!/api/Ext.data.Store).

    Thanks jgarcia. It gets a little confusing when you download the latest version of Sencha Touch and try to get started with it, and then have to post in different forums depending on which part of its functionality you use. Is there a way to move the post?


    So now I know that the server is returning the data, the client's load event is being called with successful=true, but the records array has no data. Is there another way to see what is being returned to my android emulator?

  4. #4
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,361
    Answers
    102
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    I've moved your thread, as requested. As far as inspecting, you should be able to develop your app almost entirely in your desktop without the use of your emulator. It's only when you nee to test device-specific items, should you migrate to your emulator.

    I'm not an android dev, so I can't help in that regard. My apologies.

Thread Participants: 1

Tags for this Thread