Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Grid > Conditional DetailView with Server Binding
Telerik MVC Extensions are no longer supported (see this page for reference). In case you have inquiries about Kendo UI Complete for ASP.NET MVC, post them in the pertinent Kendo UI forums.

Not answered Conditional DetailView with Server Binding

Feed from this thread
  • Sam Rossetti avatar

    Posted on Apr 30, 2012 (permalink)

    I currently have a partial view that renders the Telerik MVC Grid. The model passed to the partial view contains a bool field that states whether or not the grid should contain a detail view.

    The following code doesn't render the table but leaves the expand controls in place. Ideally I would like to hide the expand controls and the rendering of the template on the server side.

    .DetailView(detailView => detailView.Template(
                @<text>
                    @{ if (!Model.IsLowestLevel) {
                        @*render grid*@
                       }
                    }
                </text>))

  • Sam Rossetti avatar

    Posted on Apr 30, 2012 (permalink)

    Please disregard this post or just delete it.

  • Sam Rossetti avatar

    Posted on May 1, 2012 (permalink)

    I should of figured this out yesterday but the solution is to simply store my grid object in a variable and then check the bool in my model. Then I can modify my variable by adding the detail view on.
    @{
        var mainGrid = Html.Telerik().Grid(Model.Rows)
        .Name("Grid_" + Model.Id);
     
        if (!Model.IsEditable) {
            mainGrid = mainGrid.DetailView(detailView => detailView.Template(
                @<text>
                    @* Render Grid here *@
                </text>
            ));
        }
         
        mainGrid.Render();  
        }

  • Jesse avatar

    Posted on Jun 29, 2012 (permalink)

    Sam, thanks for sharing your solution.  This was exactly what I needed to do as well.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > Grid > Conditional DetailView with Server Binding
Related resources for "Conditional DetailView with Server Binding"

ASP.NET MVC Grid Features  |  Documentation  |  Demos  |  Telerik TV ]