Extjs 4.2.1 – config autoLoad:false失败

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了Extjs 4.2.1 – config autoLoad:false失败脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我定义了一个treepanel扩展扩展:’Ext.tree.Panel’和inITcomponent函数一样
Ext.define('Example',{
    extend: 'Ext.tree.Panel',title: 'Example',useArrows:false,rootVisible: false,border: false,initComponent: function () {
        VAR Store = Ext.create('Ext.data.TreeStore',{
            fields: [
                {name: 'id',tyPE: 'string'},{name: 'text',type: 'string'}
            ],autoLoad : false,// not working
            Proxy: {
                type: 'ajax',url: 'data.PHP',reader: {
                    type: 'json',root: 'results'     
                }
            }

        });
        this.store = store;
        this.callParent(arguments);
    }
 });

我尝试设置autoLoad:false但是当我创建我的treepanel时总是加载

当我尝试配置下面的代码存储然后autoLoad:false工作但加载后我的treepanel是空白

root: {
                    text: 'Ext JS',id: 'src',expanded: false // this 
                }

如果不使用root配置,我的json很好并且正常工作

({  "results": [
    { 
        id : '1',text : '1',expanded: true,results :[{ 
            id : '2',text : '2',leaf:true
        }]
    },{ 
        id : '3',text : '3',leaf:true
    }] 
})

如何解决这个问题.

您必须重写Ext.tree.Panel.setRootNode metod以考虑商店的autoLoad属性.

以下示例使用ExtJS v4.2.2进行测试.

Ext.define('Example',/**
     * override.
     */
    setRootNode: function() {
        if (this.getStore().autoLoad) {
            this.callParent(arguments);
        }
    },PRoxy: {
                type: 'ajax',url: '/data.PHP',root: 'results'
                }
            }

        });
        this.store = store;
        this.callParent(arguments);
    }
});

Ext.onReady(function(){

    var tree = Ext.create('Example',{
        renderTo: Ext.getBody(),width: 300,height: 300
    });

    tree.getStore().load();
});

脚本宝典总结

以上是脚本宝典为你收集整理的Extjs 4.2.1 – config autoLoad:false失败全部内容,希望文章能够帮你解决Extjs 4.2.1 – config autoLoad:false失败所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。