1

I'm trying to get a custom popup editor working in our Grid using MVC wrappers.

The MVC wrapper is

Html.Kendo().Grid(@Model.ReferralCommentsViewModel.ReferralComments)   
    .Name("gridComment")
    .Columns(columns =>
    {
        columns.Bound(p => p.CommentValue).Title("Comment").Encoded(false).Width(450);
        columns.Bound(p => p.CreatedBy).Title("Created By").ClientTemplate("#= kendo.toString(CreatedBy) #").Width(100);
        columns.Bound(p => p.CreatedDate).Title("Create Date").ClientTemplate("#= kendo.toString(CreatedDate, \"MM/dd/yyyy\") #").Width(70);
        columns.Command(command => { command.Edit().Text(" "); }).Title("Edit").Width(20);
        columns.Command(command => { command.Destroy().Text(" "); }).Title("Delete").Width(20);
    })
    .ToolBar(toolbar => toolbar.Create().Text("Add new Comment"))
    .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("popupEditorTemplate").Window(w=>w.Title("Add/Edit Comment")))
    .Resizable(resize => resize.Columns(true))
    .Sortable()
    .Selectable()
    .HtmlAttributes(new { style = "height:165px;" })
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .AutoSync(false)
        .Batch(true)
        .Events(events => events.Error("error_handler"))
        .Model(model => model.Id(p => p.CommentID))
        .Create(update => update.Action("EditingPopup_Create", "Referral"))
        .Read(read => read.Action("EditingPopup_Read", "Referral"))
        .Update(update => update.Action("EditingPopup_Update", "Referral"))
        .Destroy(update => update.Action("EditingPopup_Destroy", "Referral"))

    )

The editor template is -

<script id="popupEditorTemplate" type="text/x-kendo-template">
    <label for="Created Date">Created Date:</label><Input data-bind= "value: CreatedDate" readonly="true" />
    <label for="Created By">CreatedBy:</label><Input data-bind= "value:CreatedBy" readonly="true" />
    <label for="Created By">Comments:</label>
    <textarea data-role="editor"
                      data-bind="value: CommentValue"
                      style="width: 280px"></textarea>

 </script>

No matter what options I use, I cannot get the custom edit template to display in the popup. Only the default popup is displayed. Is there something obvious missing?

Project - VS2012, MVC4

3
  • What is not working? You don't get the popup? Or you get the popup with some unexpected content? or the saving is not working? Commented Jan 3, 2014 at 20:58
  • Sorry for not finishing my question. We cannot get the custom popup edit template to display. Commented Jan 3, 2014 at 21:04
  • 1
    I suggest to read the FAQ about this configuration option: docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/…? Commented Jan 3, 2014 at 21:20

1 Answer 1

1

TemplateName should specify the name of the view which is a cshtml in the EditorsTemplate folders which MVC searches automatically.

It should not be the name of a html element which holds a Kendo template (like you did). More info about MVC EditorTemplates can be found here.

Sign up to request clarification or add additional context in comments.

1 Comment

For those who, like me, don't know where the EditorsTemplate folder is, it's at \Views\Shared\EditorTemplates .

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.