ExtJS Direct--pass scope to method

911 Views Asked by At

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

3

There are 3 best solutions below

0
On BEST ANSWER

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.

1
On

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
On