• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Valence 4.1 ExtJS 4.2.1 Question: Accessing Data Store's proxy ajax response

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Valence 4.1 ExtJS 4.2.1 Question: Accessing Data Store's proxy ajax response

    Here is some code that creates a store on the fly based off some configuration values. I did not write the code, and it appears that when this code is executed, it automatically executes the ajax request to load the store:

    Code:
            // Create the dynamic store
            var dynamicStore = Ext.create('Ext.data.Store', { 
    
                fields: [modelFields],
                id: 'dynamicStore',
                sortOnLoad: true,
                //pageSize: 25,
                proxy: {
                    type: 'ajax',
                    extraParams: {
                        pgm: this.selectedViewModelPgm,
                        action: 'getViewData',
                        inView: viewName
                    },
                    url: '/valence/vvcall.pgm',
                    reader: {
                        type: 'json',
                        rootProperty: 'datalist',
                        totalProperty: 'totalCount'
                    }
                },
                autoLoad: true,
                listeners: {
                    beforeload: {
                        fn: me.onDynamicStoreBeforeLoad,
                        scope: me
                    },
                    load: {
                        fn: function() {
                            console.log('dynamic store load called.  how do i see response?');
                        },
                        scope: me
                    }
                }
            });
    How do I "see" the response of the ajax request? I've already changed my backend to send a specially formatted response that I want the front end to respond to. However, for the life of me, I cannot determine how to get to the ajax response. As you can see, I coded a load listener in an attempt to see when/how I can get the response (it will be a json formatted response) and do something based off that response (in this case, I will display an error message on the screen).



  • #2
    If your load listener is not executing then you store is liking not being loaded. Do you see it make the call when you view network traffic in your browser dev tool?

    Comment


    • #3
      Sean,

      The load listener is firing. I can see the console log message. I'm concerned about "when" load is fired so I'm not sure if the load listener is the right "time" to look at the response. That being said, all i care about is the response within this store every time it is "loaded". More specifically, I want to be sure the response is valid before attempting to load the store.

      Comment


      • #4
        The first parameter passed to the load event is the store. The response lives on the reader of the proxy so you could access the response by:

        Code:
        load : function(str){
           var rsp = str.getProxy().getReader().rawData;
        }

        Comment

        Working...
        X