ExtJs4 load panel from URL

99封情书 提交于 2019-12-08 00:53:37

问题


In ExtJs 3x this code

Ext.getCmp('specific_panel_id').load({
    url:'url_containing_scripts.htm',
    scripts:true, 
    params:{
        something:else
    }
});

works for loading content from URL into a specific panel...

However it does not work in ExtJs 4.x.


回答1:


This also work:

Ext.define('EI.view.Viewport',{
extend: 'Ext.container.Viewport',
alias: 'widget.principal',

layout: {
    type: 'vbox',
    align: 'center',
    pack: 'center'
},

items:[
    {
        xtype: 'panel',
        title: 'Mi Documentacion',
        width: 800,
        height: 600,
        border: false,
        autoScroll: true,
        loader: {
            autoLoad:true,
            url :'http://localhost/docs/'
        }
    }

]

});



回答2:


The load method is gone from the Ext.panel.Panel in ExtJs4. As a workaround you could try to load your panel content with a regular Ext.Ajax.request and set these as items to your panel.

Example:

var itemsConfig;
Ext.Ajax.request({
url : 'url_containing_scripts.htm',
callback : function(options, success, response) {
        itemsConfig = Ext.decode(response.text);
    }
});
Ext.getCmp('specific_panel_id').add(itemsConfig);

Where url_containing_scripts.htm should have the items you want on your panel in JSON format.

In the same way you can load the whole panel with all inital configuration settings you need.




回答3:


Solved it with the following code:


dynamicPanel = new Ext.Component({
           loader: {
              url: 'url_containing_scripts.htm',
              renderer: 'html',
              autoLoad: true,
              scripts: true
              }
           });
Ext.getCmp('specific_panel_id').add(dynamicPanel);


来源:https://stackoverflow.com/questions/7495293/extjs4-load-panel-from-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!