ExtJs4 load panel from URL

核能气质少年 提交于 2019-12-06 10:36:03

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/'
        }
    }

]

});

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.

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