1
votes

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

1
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?nemesv
Sorry for not finishing my question. We cannot get the custom popup edit template to display.photo_tom
I suggest to read the FAQ about this configuration option: docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/…?nemesv

1 Answers

1
votes

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.