Partial view in kendo grid column

I have an ajax enabled kendo grid with a client template that displays data from the model to which the string is bound. (due to ajax, using columns. Sampling seems to be impossible.)

@(Html.Kendo().Grid<Model>()
    .Columns(columns =>
    {
       columns.Bound(x => x.SubModel).ClientTemplate("bla #= SomePropertyOfSubModel # bla")
    })
    .DataSource(dataSource => dataSource.Ajax())

      

This works mostly, but I am not satisfied with the result. For example, I am having trouble creating kendo controls in a template work. I would rather have preferred the partial view in the client template, but it didn't work. The farthest I got was

columns.Bound(x => x.SubModel).ClientTemplate(Html.PartialView("view", //??) //how to bind to SubModel?
.ToHtmlString())

      

Any help is appreciated.

+5


source to share


2 answers


I think you need .ToClientTemplate()

in your kendo management template,

view.cshtml

@(Html.Kendo().NumericTextBox()
      .Name("NameHere")
      .Min(0)
      .HtmlAttributes(new { style = "width:200px" })
      .ToClientTemplate()                                 
)

      

And then,



 columns.Bound(c => c.SubModel).ClientTemplate(Html.Partial("view").ToHtmlString());

      

Edit

If you want to bind the model to a partial view, you can do

columns.Bound(c => c.SubModel.Property).Template(@<text>Html.Partial("view", item.SubModel)</text>);

      

+3


source


Here's another way to do it.



 @(Html.PageElement().Kendo().Grid<myModel>()
      .Name("GridName")
      .Columns(col => 
                     Html.RenderPartial("Partials/_myDamnedPartial", col)  

      

0


source







All Articles