caoweishan_224 2012-07-04 17:59
浏览 234
已采纳

EXT4 TreeStroe 如何取消根节点

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]

  • 写回答

1条回答 默认 最新

  • works001 2012-07-04 18:23
    关注

    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]
    

    到此解决携带参数问题

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 关于#opencv#的问题:使用大疆无人机拍摄水稻田间图像,拼接成tif图片,用什么方法可以识别并框选出水稻作物行
  • ¥15 Python卡尔曼滤波融合
  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1