Client-side rendering of Partial Views

2 posts, 0 answers
  1. IT Dept
    IT Dept avatar
    15 posts
    Member since:
    May 2010

    Posted 30 Mar 2017 Link to this post

    Hello everyone, I need to fill panel bar content with partial views. My current code is

     

    @(Html.Kendo().PanelBar()
            .Name("reportFilters")
            .ExpandMode(PanelBarExpandMode.Multiple)
            .ExpandAll(true)
            .Animation(true)
            .Items(panelbar =>
            {
                foreach (IFilterCategory filterCateg in Model)
                {
                    panelbar.Add()
                     .Text(filterCateg.DisplayName)
                .Content(@<text><div style="padding-top:5px;padding-left:5px;padding-right:5px">
    @Html.Action(filterCateg.Action, filterCateg.Controller, new { filterCateg = filterCateg })</div></text>);
                }
            }
        )
    )

     

    and after reading the following post 

    http://www.telerik.com/forums/what-is-the-syntax-to-open-a-mvc-partial-page-inside-a-pannel-bar#hmqmhkbB-kyThT8J06ygng

    i tried to achieve client side rendering by using LoadContentFrom and .Action() without success. The best try was hitting the controller but the object filterCateg is null.

    Thanks in advance.

  2. Nencho
    Admin
    Nencho avatar
    1686 posts

    Posted 03 Apr 2017 Link to this post

    Hello,

    Indeed, the referenced post covers the possible scenarios to load content in the Items of the panelBar. In addition, your current implementation also seems correct. I am afraid, however, that we cannot be sure why the filterCateg is empty when you attempt to create items base on each one of them. Please make sure that the model is correctly filled and passed to the view, where you aim to use them. 

    You can event test the correct passing of the model in a separate section, not within the panelbar itself. In addition, you can try using the BindTo method, as demonstrated in the following forum thread:

    http://www.telerik.com/forums/dynamically-creating-panel-bar-items-containing-partial-views-and-models#9ALNw6_6Gk-A3s8LfDOyUA

    Regards,
    Nencho
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top