This is a migrated thread and some comments may be shown as answers.

PopUp Editing - custom PopUp-Window (not EditorTemplate!)

4 Answers 504 Views
Grid
This is a migrated thread and some comments may be shown as answers.
BigzampanoXXl
Top achievements
Rank 1
BigzampanoXXl asked on 29 May 2013, 01:06 PM
Hello,

I'm trying to make a grid with PopUp-Mode. Now I need a customized content for the editing-window. I know it is possible to define a "TemplateName" which directs to an EditorTemplate. But in this case I'm not allowed to use an EditorTemplate for different reasons.

I saw in other posts (eg: http://www.kendoui.com/forums/ui/grid/custom-popup-editor-with-additional-fields.aspx#MtaYNNFFv0aHX5-drisScg ) where the Grid was not initialized by the MVC-wrapper, that it is possible to define a template which uses a script (type="text/x-kendo-template") like the following:
<script id="gridEditTemplate" type="text/x-kendo-template">
    Content here
</script>
So in my case I also want to use this kind of template for the editing-window.

Here is my Code of the Grid:
@(Html.Kendo().Grid(Model.Amounts)
    .Name("MyGrid")
    .BindTo(Model.Amounts)
    .ToolBar(commands => commands.Create().Text("add"))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Events(ev => ev.Change("onChange"))
        .Update("Update", "Special")
        .Destroy("Delete", "Special")
        .Create("Insert", "Special")
    .Model(model =>
    {
        model.Id(p => p.ID);
        model.Field(p => p.Amount);
        model.Field(p => p.Type);
    }).ServerOperation(false))
    .Columns(columns =>
    {
        columns.Bound(p => p.Amount).Title("Amount");
        columns.Bound(p => p.Type).Title("Type).Width(70);
        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(160);
    })
    .Editable(editable => editable.Mode(GridEditMode.PopUp).CreateAt(GridInsertRowPosition.Bottom).Window(w => w.Title("Amounts: ")))
)

So what can I do to use a specific template-script? I can't use an EditorTemplate.

Thank you!

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 31 May 2013, 07:43 AM
Hi,

 If you want to use a script for an editor template you need to use the JavaScript version of the Kendo UI Grid. For the ASP.NET MVC wrapper you should use and editor template.

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
BigzampanoXXl
Top achievements
Rank 1
answered on 04 Jun 2013, 07:42 AM
Hi Atanas and thank you for your reply,

well, thats a little bit disappointing if something which is available in the javascript-version can't be set by the MVC wrapper. But actually the rendered grid should be the same right? So at least there has to be a way to set the called Template manually (e.g. in the document ready) to such a script-area right? Can you say me how this is possible?

Thanks
0
Accepted
Atanas Korchev
Telerik team
answered on 04 Jun 2013, 08:59 AM
Hello Dietmar,

 Yes, this is a possible workaround. Something like this would work:

$(function() {
        var grid = $("#grid").data("kendoGrid");
        grid.options.editable.template = "<input data-bind='value:ProductName' />"; // new editor template
 });

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
BigzampanoXXl
Top achievements
Rank 1
answered on 12 Jun 2013, 08:06 AM
Thanks Atanas, that worked very well.

But unfortunately we can't use it as we liked to. The text/x-kendo-template can't get rendered as soon as we have an EditorFor in it. TextBoxFor and all the other controls seem to work. EditorFor not. So we switched to our own implementation of a popup, rebinding everything with javascript. Not the best solution but better than no solution :)

Thanks again
Tags
Grid
Asked by
BigzampanoXXl
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
BigzampanoXXl
Top achievements
Rank 1
Share this question
or