---
title: "EXT portal布局 动态添加items问题"
author: "lauy"
date: "2012-06-07T07:41:46Z"
tags: ["EXT portal"]
categories: ["Web前端"]
slug: "ext-portal-items"
draft: false
lastmod: "2012-06-07T07:43:23Z"
id: 1553899
url: "https://lauy.iteye.com/blog/1553899"
---

现在需要动态添加portal布局中的panel，前期静态放置到portal布局中的panel可以完全正常，而在生成后add进去的panel，可以正常显示


```Javascript
Ext.onReady(function(){
    var viewport = new Ext.Viewport({
        layout:'border',
        items:[{ 
            xtype:'portal',
            region:'center',
            margins:'35 5 5 0',
            items:[{
                columnwidth:.33,
                style:'padding:10px 0 10px 10px',
                items:[{
                    title: 'grid in a portlet',
                    layout:'fit'
                },{
                    title: 'another panel 1',
                    html: ext.example.shortbogusmarkup
                }]
            },{id:"abc",
                columnWidth:.33,
                style:'padding:10px 0 10px 10px',
                items:[{
                    title: 'panel 21',
                    html: ext.example.shortbogusmarkup
                },{
                    title: 'another panel 22',
                    html: ext.example.shortbogusmarkup
                }]
            },{id:"ccc",
                columnWidth:.33,
                style:'padding:10px',
                items:[{
                    title: 'panel 31',
                    html: ext.example.shortbogusmarkup
                },{
                    title: 'panel 32',
                    html: ext.example.shortbogusmarkup
                },{id:"bb",
                    title: 'another panel 33',
                    html: ext.example.shortbogusmarkup
                }]
            }]
        }]
    });

 var pan1 = new Ext.Panel({
		title : 'new panel',
		html : "新panel，不能正常拖动",
		anchor : '100%',
		frame : true,
		collapsible : true,
		draggable : true,
		cls : 'x-portlet'
	});


  Ext.getCmp('abc').add(pan1);
  Ext.getCmp('abc').doLayout();
});

```