0

I'm using the ExtJS Direct proxy and need to know how to pass scope when calling a method. Currently im doing this

myapp.direct.action.mygridservice.getGridData("123",this.getSearchCbo().getValue(), function(p_,resp_){
          //do something
      }, this);  

on the java method I added a third param for scope with type String but i still get an error that "this" is undefined

thanks

stackato
  • 1,085
  • 1
  • 19
  • 38

3 Answers3

1

1.- The scope parameter that you are passing is not to the backend but to your callback function. (function to execute once the server side responds)

2.- If you want to pass more information to the backend it needs to be passed in an object before the callback function and the scope.

Example:

    var jsObject = {//put all the info you need to send to the server so you dont have 50 params}

    myapp.direct.action.mygridservice.getGridData("123",comboValue, jsObject someFunction, this); 

Passing this as the scope will enable you to access some variables that otherwise will not be reachable.

Do:

console.log(this);

on your callback function.

code4jhon
  • 5,725
  • 9
  • 40
  • 60
0

Try this one:

loadData: function () {    
  RemoteManager.loadData(param1,param2, this.callbackLoadData, this);
},

callbackLoadData: function (result, e) {
   var t = e.getTransaction();
   var ctl = t.args[t.args.length - 1];
}
0

Maybe you should wrap your callback function.

Check this links.

Passing Extra Data to Callbacks https://www.sencha.com/forum/showthread.php?188184-set-scope-of-Ext.Direct-callback-handler

Jairo R. Flores
  • 724
  • 4
  • 11