[CLOSED] Loading Partial View within a Portlet

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Loading Partial View within a Portlet

    I'm having trouble loading a partial view inside of a portlet. With the code below, only the ext.net button control loads inside the portlet, all other html within the partial view is displayed outside of the porlets.

    Am I missing an ext.net container of some kind to load the partial view in?

    Please don't link me to the examples, I've looked there already.

    Thank you,
    Rob

    --

    Main View

    
    @functions 
    {
        private Ext.Net.Portlet.Builder InitPortlet(IWidgetWrapper widgetModel)
        {
            var portletBuilder = new Ext.Net.Portlet.Builder();
                
            switch (widgetModel.WidgetId)
            {
                case 1:
                    portletBuilder.ItemsFromPartial("~/Views/Shared/Widgets/_AlertsWidget.cshtml", widgetModel as AlertsWidgetViewModelDTO);
                    break;
                default:
                    portletBuilder.ItemsFromPartial("~/Views/Shared/Widgets/_ErrorWidget.cshtml");
                    break;
            }
    
            return portletBuilder;
        }
    
    }
    
    <div>
        @(Html.X().ResourceManager(ViewBag.ManagerConfig as MvcResourceManagerConfig).RenderStyles(ResourceLocationType.None))
    
        @(Html.X().Portal().ID("Dashboard_Portal").Border(false).Layout(Ext.Net.LayoutType.Fit)
                .Items(Html.X().Portal()
                            .Items(Html.X().PortalColumn().Cls("x-column-padding")
                                    .Items(portlets =>
                                        {
                                            foreach (var widgetModel in Model.WidgetContents)
                                            {
                                                IWidgetWrapper thisWidget = widgetModel;
                                                portlets.Add(InitPortlet(widgetModel));
                                            }
                                        })
                           )))    
     </div>
    Partial View

    
    @model PR.DTO.AlertsWidgetViewModelDTO
    
    <div>
        <h3>Alerts Widget</h3>
        <p>
            This is where some alerts will go
        </p>
        <br />
        @Html.X().Button().Icon(Icon.Application).Text("Ext.Net button - click").Handler("Ext.Msg.alert('Ext.NET button', 'Hello');")
    
    </div>
    Last edited by Daniil; Jul 23, 2013 at 12:55 PM. Reason: [CLOSED]
  2. #2
    ItemsFromPartial works with Ext.Net widgets only
    Please use ContentFromPartial
  3. #3
    Quote Originally Posted by Vladimir View Post
    ItemsFromPartial works with Ext.Net widgets only
    Please use ContentFromPartial
    Using ContentFromPartial renders the html in my partial view but now my ext.net button control does not render.

    I have both ext.net controls and html in my partial view and I want to render them both within a Portlet.

    How can I achieve this?

    Thanks
    -Rob

    Main View

    <link href="~/Content/thirdPartyCss/ext_custom_graythem.css" rel="stylesheet" />
    <div>
        
        @functions 
        {
            private Ext.Net.Portlet.Builder InitPortlet(IWidget widgetModel)
            {
                var portletBuilder = new Ext.Net.Portlet.Builder();
    
                switch (widgetModel.WidgetId)
                {
                    case 100:
                        portletBuilder.ContentFromPartial("~/Views/Widgets/_WidgetAlerts.cshtml", widgetModel as WidgetModelAlerts);
                        break;
                }
    
                return portletBuilder;
            }
    
        }
    
        @(Html.X().ResourceManager(this.ViewBag.ManagerConfig as MvcResourceManagerConfig).RenderStyles(ResourceLocationType.None))
    
        @(Html.X().Portal().ID("Dashboard_Portal").Border(false).Layout(Ext.Net.LayoutType.Fit)
                .Items(Html.X().Portal()
                            .Items(Html.X().PortalColumn()
                                    .Cls("x-column-padding")
                                    .Items(portlets =>
                                        {
                                            foreach (var widgetModel in Model.Widgets)
                                            {
                                                IWidget thisWidget = widgetModel;
                                                portlets.Add(InitPortlet(thisWidget));
                                            }
                                        })
                            )))
    
        
    
    </div>
    Partial View

    @using Ext.Net
    @using Ext.Net.MVC
    
    @model SandboxOneMvc.Models.WidgetModelAlerts
    
    <div>
        <h3>Alerts Widget - WidgetId: @(Model.WidgetId)</h3>
        <p>
            This is where some alerts will go
        </p>
        <br />
        @Html.X().Button().Icon(Icon.Application).Text("Ext.Net button - click").Handler("Ext.Msg.alert('Ext.NET button', 'Hello');")
     
    </div>
  4. #4
    Are you sure that button is not rendered? Try to set enough height for portlets
  5. #5
    You're right, the button was hidden.

    Setting the Height or the MinHeight resolved the issue, see code below.

    Is there a property or method that will auto adjust the height to fit the contents of the portlet?

    Thank you
    -Rob

        @functions 
        {
            private Ext.Net.Portlet.Builder InitPortlet(IWidget widgetModel)
            {
                var portletBuilder = new Ext.Net.Portlet.Builder();
    
                switch (widgetModel.WidgetId)
                {
                    case 100:
                        portletBuilder.ContentFromPartial("~/Views/Widgets/_WidgetAlerts.cshtml", widgetModel as WidgetModelAlerts);
                        portletBuilder.MinHeight(160);
                        break;
                }
    
                return portletBuilder;
            }
    
        }
  6. #6
    This helps.
    portletBuilder.AutoDoLayout(true);
    However, be careful with this setting, because it can slow down initial rendering.

Similar Threads

  1. [CLOSED] Loading a partial view in Table Format
    By pawangyanwali in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 23, 2012, 12:44 PM
  2. [CLOSED] [2.1] MVC Partial View
    By softmachine2011 in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Aug 23, 2012, 12:04 PM
  3. [CLOSED] Loading Partial View under a formpanel
    By Daly_AF in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 25, 2012, 2:26 PM
  4. [CLOSED] Loading panel with MVC partial view
    By bbo1971 in forum 2.x Legacy Premium Help
    Replies: 26
    Last Post: Jul 25, 2012, 1:04 AM
  5. [CLOSED] Error loading partial view in Tab.
    By SymSure in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 20, 2011, 8:00 PM

Tags for this Thread

Posting Permissions