extjs6.0異步樹,當點擊節點的時候,需要重新發送請求,就需要在beforeload的方法里面處理接口的傳參;默認進入接口傳參,需要在extraParams對象中設置;
Ext.create('Ext.data.TreeStore', {
storeId:'Template', // 數據集ID
root: { // 根節點配置
id: '400', // 根節點ID
expanded: true, // 默認展開
text: '模板' // 根節點名稱
},
proxy: { // 訪問代理
type: 'ajax', // 類型異步
// 請求方式為post
actionMethods: {
read: 'POST'
},
api: {
read: 'test/testUrl' //接口
},
//接口 需要的參數
extraParams: {
path : ' '
},
listeners:{
// 主要處理節點展開時的傳參
beforeload: function (_this,operation) {
var node = operation.data;
if(!node){
node = operation.node
}
//獲節點的路徑
if (node.data && node.data.node) {
_this.getProxy().extraParams.path = node.data.node.path
}
}
}
},
})