How to dynamically add a grid from a partial view?

  1. #1

    How to dynamically add a grid from a partial view?

    Given partial view:
    @{
        Layout = null;
    }
    
    @(Html.X().GridPanel()
                                                                    .Header(false)
                                                                    .Border(false)
                                                                    .Store(Html.X().Store()
                                                                        .AutoLoad(true)
                                                                        .Proxy(
                                                                            Html.X().AjaxProxy()
                                                                                .Url(Url.Action("GetMyRecommendations", "api/Recommendations"))
                                                                                .ActionMethods(actions =>
                                                                                {
                                                                                    actions.Read = HttpMethod.GET;
                                                                                })
                                                                                .Reader(
                                                                                    Html.X().JsonReader().Root("result")
                                                                                )
                                                                        )
                                                                        .Model(Html.X().Model()
                                                                            .Fields(
                                                                                new ModelField("RecommendedDisplayName"),
                                                                                new ModelField("RecommenderUserDisplayName"),
                                                                                new ModelField("TitleAtCompany")
                                                                            )
                                                                        )
    
                                                                    )
                                                                    .ColumnModel(
                                                                        Html.X().Column().Text("Recommended DisplayName").DataIndex("RecommendedDisplayName").Flex(1),
                                                                        Html.X().Column().Text("Recommender DisplayName").DataIndex("RecommenderUserDisplayName").Flex(1),
                                                                        Html.X().Column().Text("Title").DataIndex("TitleAtCompany")
    
                                                                        )
                                                                        )
    then from a regular view what is the best way dyamically load it in to a Portlet?:
    columns.Add(Html.X().PortalColumn()
                                                        .Cls("x-column-padding")
                                                        .MarginSpec("0 10 0 10")
                                                        .Flex(1)
                                                        .Items(portlets =>
                                                        {
                                                            portlets.Add(Html.X().Portlet()
                                                                .Title("Employees")
                                                                .Layout(LayoutType.Fit)
                                                                .Anchor("100% 100%")
                                                                .Closable(false)
                                                                .Items(
                                                                    Html.X().Container()
            .ID("ViewContainer2")
            .StyleSpec("border:solid 1px black; height:150px; width:300px;")
            .Loader(Html.X().ComponentLoader()
                .Url(Url.Action("AutoLoadPartialView"))
                .Mode(LoadMode.Script)
                .Params(new { containerId = "ViewContainer2", viewName = "_MyRecommendations" })
            )
                                                                )
    
                                                                );
                                                        }));
  2. #2
    If you don't to load a view on demand (from client side) then you can use the following approaches
    http://mvc.ext.net/#/Items/Action/
    http://mvc.ext.net/#/Items/Page/

    If you need to load on demand then use the following approache
    http://mvc.ext.net/#/Dynamic_Partial...Partial_Items/

Similar Threads

  1. [MVC] How to use a partial view in a window?
    By KBorkiewicz in forum 2.x Help
    Replies: 7
    Last Post: Nov 21, 2012, 11:11 PM
  2. [CLOSED] Partial View With Linked Combos
    By rbarr in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Sep 05, 2012, 12:26 PM
  3. [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
  4. [CLOSED] Dynamically Added Tab not rendering partial view
    By SymSure in forum 1.x Legacy Premium Help
    Replies: 13
    Last Post: Apr 26, 2011, 9:10 PM
  5. Replies: 6
    Last Post: Feb 15, 2010, 9:15 AM

Posting Permissions