javajavascriptextjsext-direct

ExtJS Direct--pass scope to method


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


Solution

  • 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.