Wednesday, June 12, 2013

Extjs: store.proxy.extraParams is undefined only in Internet Explorer 8; works fine in FF, chrome


White walker from Game of Thrones season 3


Just done with the Game of Thrones's last episode of season 3.
It has left me both sad and happy at the same time.
Sad cause no more game of thrones for quite sometime now.
Happy cause now I have time to do other things, one of which is writing today's post.

Today I faced this very peculiar problem while working with ExtJS store.
I was testing my code in Google Chrome and was quite happy to see it work like a charm.
Then I tried to check the same screen in IE8 and bam! It crashed!!

Reason being:
store.proxy.extraParams is undefined

Now let me show you my store first:
 var fieldsStore = new Ext.create('Ext.data.Store', {  
      model : 'FieldsModel',  
      proxy : {  
           type : 'ajax',  
           url : 'action_getDetails',  
           extraParams : {  
                queryID : queryID  
           },  
           reader : {  
                type : 'json'  
           }  
      }  
 });  

So in my store I had an extraParams field which I was setting before loading the store.
This is what I was doing earlier

fieldsStore.proxy.extraParams.queryID = arrQuery.queryId; //set extraparams field
fieldsStore.load() //load the store

And this was working perfectly fine in Chrome as well as Firefox.
But turns out it gave error in my IE8.

After googling a bit I even tried calling it in this way

fieldsStore.getProxy().setExtraParam('queryID', arrQuery.queryId); //set extraparams field

This time it said
Object doesn't support this property or method

Damn, this was mind boggling and annoying at the same time.
Later, thanks to a lot of tweaking in the chrome developer tool, I found this alternative:

fieldsStore.proxy.extraParams = {queryID : arrQuery.queryId};

Apparently this worked in all of the above mentioned browsers!
Honestly I am still trying to figure out the reason why IE8 wants a JSON while other browsers don't throw any of such tantrums. So for now am gonna continue with the above fix.

Please post your comments and alternatives (if any) to this issue.

3 comments:

  1. That's totally weird. What version of ExtJS were you using? I didn't see this behavior with ExtJS 4.1.1a on either XP or Win7 using IE8.

    ReplyDelete
  2. Just want to say your article is astounding. The clarity in your post is simply spectacular
    access Monova in UK

    ReplyDelete