TreeStroe load 时除了正常请求外还附带了一个node=root的请求,如何取消该请求?
Console:
GET http://localhost:8080/Accordion/treenode/view.action?_dc=1341394277181&node=root 400 (Bad Request) ext-all-debug.js:17836
VIEW CODE:
[js]
initComponent: function() {
var me = this;
...
callback: function(records,operation,success){
for ( var i = 0; i < this.data.length; i++) {
me.add(Ext.create("Ext.tree.Panel", {
title : ''+this.getAt(i).data.nodename+'',
iconCls : 'node-'+i,
rootVisible : false,
viewConfig : {loadingText : "Menu Loading.."},
store : Ext.create('PersonMani.store.TreeNodes').load({
params: {tpid: this.getAt(i).data.id}
})
}));
...
});
me.callParent(arguments);
}
[/js]
STORE CODE:
[js]
Ext.define('PersonMani.store.TreeNodes', {
extend: 'Ext.data.TreeStore',
requires: 'PersonMani.model.TreeNode',
model: 'PersonMani.model.TreeNode',
proxy: {
type: 'ajax',
api: {
read : 'treenode/view.action'
},
reader: {
type: 'json',
root: 'data',
successProperty: 'success'
},
root: {
id: 'rootNode',
text: 'Root',
expanded: false,
rootVisible:false,
},
listeners: {
exception: function(proxy, response, operation){
Ext.MessageBox.show({
title: 'REMOTE EXCEPTION',
msg: operation.getError(),
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
}
}
}
});
[/js]
treestore再请求时会默认携带参数 参数名是nodeParam定义的值
请看treestore的源码:
[code="java"] load: function(options) {
options = options || {};
options.params = options.params || {};
var me = this,
node = options.node || me.tree.getRootNode(),
root;
// If there is not a node it means the user hasnt defined a rootnode yet. In this case lets just
// create one for them.
if (!node) {
node = me.setRootNode({
expanded: true
}, true);
}
if (me.clearOnLoad) {
if(me.clearRemovedOnLoad) {
// clear from the removed array any nodes that were descendants of the node being reloaded so that they do not get saved on next sync.
me.clearRemoved(node);
}
// temporarily remove the onNodeRemove event listener so that when removeAll is called, the removed nodes do not get added to the removed array
me.tree.un('remove', me.onNodeRemove, me);
// remove all the nodes
node.removeAll(false);
// reattach the onNodeRemove listener
me.tree.on('remove', me.onNodeRemove, me);
}
Ext.applyIf(options, {
node: node
});
options.params[me.nodeParam] = node ? node.getId() : 'root'; //这行就看出来了 携带参数了 你可以重写load方法 在这行做判断是否加参数
if (node) {
node.set('loading', true);
}
return me.callParent([options]);
},[/code]
到此解决携带参数问题