ExtJS Direct——将作用域传递给方法

ExtJS Direct--pass scope to method

我正在使用 ExtJS Direct 代理,需要知道在调用方法时如何传递范围。目前我正在做这个

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

在 java 方法上,我为类型为 String 的范围添加了第三个参数,但我仍然收到 "this" 未定义

的错误

谢谢

试试这个:

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];
}

也许你应该包装你的回调函数。

检查此链接。

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

1.- 您传递的范围参数不是传递给后端,而是传递给回调函数。 (服务器端响应后执行的函数)

2.- 如果要向后端传递更多信息,则需要在回调函数和范围之前传递一个对象。

示例:

    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); 

传递 this 作为作用域将使您能够访问一些否则无法访问的变量。

做:

console.log(this);

关于你的回调函数。