使用ExtJS TreeLoader发送参数

使用ExtJS TreeLoader发送参数,extjs,Extjs,当baseParams通过dataUrl发送到服务器时,是否可以更改ExtJS创建的URL的结构 例如,按如下方式设置baseParams: baseParams: { category: 2 }, dataUrl:'testclass.php' 将创建以下请求字符串: testclass.php?category=2 我要做的是以restful方式检索数据,如下所示: testclass/category/2 ExtJS可以使用这种URL结构吗?谢谢 当然,您可以编写自己的Tre

当baseParams通过dataUrl发送到服务器时,是否可以更改ExtJS创建的URL的结构

例如,按如下方式设置baseParams:

baseParams: {
    category: 2
},
dataUrl:'testclass.php'
将创建以下请求字符串:

testclass.php?category=2
我要做的是以restful方式检索数据,如下所示:

testclass/category/2

ExtJS可以使用这种URL结构吗?谢谢

当然,您可以编写自己的TreeLoader,这将是IIRC的唯一方法。

我认识到这不是一个理想的解决方案,而且这个问题有点陈旧,但这段代码在这里对我来说相当有效:

Ext.override(Ext.tree.TreeLoader, {
    requestData : function(node, callback, scope) {
        var originalDataUrl = this.dataUrl;
        this.dataUrl += "/" + this.getParams(node).node;
        if(this.fireEvent("beforeload", this, node, callback) !== false){
            if(this.directFn){
                var args = this.getParams(node);
                args.push(this.processDirectResponse.createDelegate(this, [{callback: callback, node: node, scope: scope}], true));
                this.directFn.apply(window, args);
            }else{
                this.transId = Ext.Ajax.request({
                    method:this.requestMethod,
                    url: this.dataUrl||this.url,
                    success: this.handleResponse,
                    failure: this.handleFailure,
                    scope: this,
                    argument: {callback: callback, node: node, scope: scope}
                    //params: this.getParams(node)
                });
            }
        }else{
            // if the load is cancelled, make sure we notify
            // the node that we are done
            this.runCallback(callback, scope || node, []);
        }
        this.dataUrl = originalDataUrl;
    }
});

真的,唯一的缺点是在这条路上完全没有参数。在我的例子中,我只需要节点ID。但是,如果您想重写加载方法,这至少应该为您提供一个良好的起点!:)

为此干杯,我还没来得及添加此功能,这将使deffo派上用场。助教。