2010-09-24 36 views
1

當baseParams通過dataUrl發送到服務器時,是否可以更改由ExtJS創建的URL的結構?使用ExtJS發送參數TreeLoader

例如,因爲它代表設置baseParams如下:

baseParams: { 
    category: 2 
}, 
dataUrl:'testclass.php' 

將創建下列請求字符串:

testclass.php?category=2 

我想要做的就是在一個寧靜的方式檢索數據像這樣:

testclass/category/2 

這個URL結構可能與ExtJS?謝謝。

回答

1

你當然可以編寫自己的TreeLoader,這將是IIRC的唯一途徑。

+0

我以爲很多,謝謝。 – 2010-09-24 08:46:24

1

我承認,這不是一個理想的解決方案,而這個問題是有點老了,但是這個代碼已經工作得相當好,我在這個場地:

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。但是如果你想覆蓋你的加載方法,這應該至少給你一個很好的起點! :)

+0

爲此歡呼,我還沒有加入這個功能,這將deffo派上用場。助教。 – 2010-10-19 15:31:57