1

I'm trying to use the Kendo Mvc Grid as a Mvc EditorTemplate like so.

ViewModel.cs

public class ViewModel{
  ...
  public List<EditorViewModel> Lines{get;set;}
  ...
}

EditorViewModel.cs

public class EditorViewModel{
   ...
   public string Text{get;set;}
   ...
}

View.cshtml

@model ViewModel
<form>
   ...
   @Html.EditorFor(m => m.Lines, "Grid")
   ...
</form>

EditorTemplates/Grid.cshtml

@Model IEnumerable<EditorViewModel>
@Html.Kendo().Grid<EditorViewModel>().BindTo(Model)
...
.Columns(col => {
  col.Bound(m => m.Text)**.EditorTemplate("Text.Grid");**
})
.Editable(g => g.Enabled(true).Mode(GridEditMode.InCell))
...
)

The Grid is displayed correctly and is editable as excepted, but when I'm leaving the edit mode a javascript error is thrown.

Uncaught TypeError: Cannot read property 'Text' of undefined
at eval (eval at getter (kendo.all.js:2041), <anonymous>:3:21)
at init.set (kendo.all.js:8149)
at init.change (kendo.all.js:8930)
at init.f (jquery-2.2.4.min.js:2)
at init.trigger (kendo.all.js:124)
at init.window.kendo.window.kendo.devtools.kendo.ui.Widget.trigger (<anonymous>:587:33)
at init._change (kendo.all.js:35754)
at init._blur (kendo.all.js:35719)
at init._focusout (kendo.all.js:35770)
at HTMLInputElement.f (jquery-2.2.4.min.js:2)

Is it possible to use a KendoGrid as Mvc EditorTemplate? And if it is possible what am I doing wrong?

UPDATE:

If found a solution for this problem. Changes made is with bold text. In the Text.Grid.cshtml you add this line

@{
  ViewData.TemplateInfo.HtmlPrefix = string.Empty;
}

this way the property prefix is removed

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.