Monday, November 9, 2015

EXTJS: Model ID appended to the AJAX/REST URL

While verifying the upgrade to EXTJS 6, I noticed that the URL(AJAX/REST) had the model id appended to it. Because of this, the calls were not reaching the server.
To mitigate this issue, I used the following fix:
Add the below snippet in the beforesync() listener in the store.

 beforesync: function(){  
    Ext.override(Ext.data.proxy.Rest, {  
     buildUrl: function(request) {  
      for (var i = 0; i< arguments.length; i++) {  
       if(arguments[i]._action != "read" && arguments[i]._records != undefined){  
        var argData = arguments[i]._records[0];  
        delete argData.id;  
       }  
      };  
      return this.callParent(arguments);  
     } });  
    }  

No comments:

Post a Comment