[CLOSED] [2.x] - MVC - Dynamic PortalColumn

  1. #1

    [CLOSED] [2.x] - MVC - Dynamic PortalColumn

    Hi,

    I try to create a dynamic PortalColumn and run into the error "TypeError: items[0] is undefined.

    items[0].addCls('x-portal-column-first');".

    I wonder what is the issue.

    Following is my test.

    View
    @{
        ViewBag.Title = "Server Status Center";
        var X = Html.X();
    }
    
    @(X.ResourceManager())
    @(X.Portal()
            .ID("Portal_Main")
            .Region(Region.Center)
            .Border(false)
            .Flex(1)
            .BodyStyle("background-color:transparent")
            .Loader(X.ComponentLoader().Url(Url.Action("RenderServerStatusColumn")).Mode(LoadMode.Component).Params(new { containerId = "Portal_Main" })) 
    )
    Controller
    public ContentResult RenderServerStatusColumn(string containerId)
            {
                var compLoader = new ComponentLoader
                {
                    Url = Url.Action("http://www.ext.net"),
                    DisableCaching = true,
                    Mode = LoadMode.Frame,
                };
                var portalcolumn = new PortalColumn { ID = "PortalColumn_01", ColumnWidth = 0.5 };
                return Content(ComponentLoader.ToConfig(
                
                new List<AbstractComponent>()
                {
                     portalcolumn
                }
                ));
            }
    Last edited by Daniil; Jul 03, 2013 at 3:39 AM. Reason: [CLOSED]
  2. #2
    Hi @drkoh,

    Yes, I see that a Portal doesn't support no PortalColumn for initial state. I would consider it a bug.

    Please try this fix (add to the page's <head>).

    Fix
    Ext.app.PortalPanel.override({
        beforeLayout: function () {
            var items = this.layout.getLayoutItems(),
                len = items.length,
                i = 0,
                cw = 1,
                cwCount = len,
                item;
    
            for (i = 0; i < len; i++) {
                item = items[i];
    
                if (item.columnWidth) {
                    cw -= item.columnWidth || 0;
                    cwCount--;
                }
            }
    
            for (i = 0; i < len; i++) {
                item = items[i];
                if (!item.columnWidth) {
                    item.columnWidth = cw / cwCount;
                }
                item.removeCls(['x-portal-column-first', 'x-portal-column-last']);
            }
    
            if (items.length > 0) {
                items[0].addCls('x-portal-column-first');
                items[len - 1].addCls('x-portal-column-last');
            }
    
            return this.callParent(arguments);
        }
    });
  3. #3
    Hi Daniil,

    I added the script to the <head>, as following and still get the items[0] is undefined error.

    
    <head>    <script type="text/javascript">        Ext.app.PortalPanel.override({            beforeLayout: function () {                var items = this.layout.getLayoutItems(),                    len = items.length,                    i = 0,                    cw = 1,                    cwCount = len,                    item;                 for (i = 0; i < len; i++) {                    item = items[i];                     if (item.columnWidth) {                        cw -= item.columnWidth || 0;                        cwCount--;                    }                }                 for (i = 0; i < len; i++) {                    item = items[i];                    if (!item.columnWidth) {                        item.columnWidth = cw / cwCount;                    }                    item.removeCls(['x-portal-column-first', 'x-portal-column-last']);                }                 if (items.length > 0) {                    items[0].addCls('x-portal-column-first');                    items[len - 1].addCls('x-portal-column-last');                }                 return this.callParent(arguments);            }        });    </script></head>
  4. #4
    Please change to:
    Ext.app.PortalPanel.override({
        beforeLayout: function () {
            var items = this.layout.getLayoutItems(),
                len = items.length,
                i = 0,
                cw = 1,
                cwCount = len,
                item;
     
            for (i = 0; i < len; i++) {
                item = items[i];
     
                if (item.columnWidth) {
                    cw -= item.columnWidth || 0;
                    cwCount--;
                }
            }
     
            for (i = 0; i < len; i++) {
                item = items[i];
                if (!item.columnWidth) {
                    item.columnWidth = cw / cwCount;
                }
                item.removeCls(['x-portal-column-first', 'x-portal-column-last']);
            }
     
            if (items.length > 0) {
                items[0].addCls('x-portal-column-first');
                items[len - 1].addCls('x-portal-column-last');
            }
     
            return Ext.app.PortalPanel.superclass.beforeLayout.apply(this, arguments);
        }
    });
  5. #5
    Great, it works. Thanks.
  6. #6
    We added the fix to SVN. So, after update you could remove the fix on your side.

    Thank you for the report!

Similar Threads

  1. Replies: 0
    Last Post: Jun 17, 2013, 11:05 AM
  2. [CLOSED] Resize and hide PortalColumn
    By kwcitadmin in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 14, 2013, 6:41 AM
  3. Replies: 1
    Last Post: Nov 12, 2012, 1:21 PM
  4. Replies: 13
    Last Post: Jan 23, 2012, 9:37 AM
  5. Replies: 12
    Last Post: Sep 20, 2011, 2:33 PM

Posting Permissions