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

How to use Different Templates For Edit and Create Operations

1 Answer 480 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nurali
Top achievements
Rank 1
Nurali asked on 04 Dec 2013, 03:33 PM
I am using Kendo Grid for Edit,Update,Delete user Informations.

I want to use different templates for edit and create opetation.
Currently:

.TemplateName("EditPerson"))

With this  i created a  view file(name is EditPerson.cshtml) under "EditorTemplates" folder.
i want to use another template for Create Operations.How can i do it?

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 04 Dec 2013, 04:18 PM
Hello Nurali,


It is not possible to define a separate template for the Create operation, but I would suggest you an alternative solution. You could add custom classes to the editor fields for the edit and for the create operations or even wrap them in separate elements in the editor template.
E.g.
<div class="forEdit"> ... </div>
<div class="forCreate"> ... </div>

Then you should bind to the edit event of the Grid, determine whether the current operation is create or update and remove the elements that are not needed.
E.g.
.Events(e => e.Edit("Edit"))

function Edit(e) {
    if (e.model.isNew()) {
        $(".forEdit").remove();
    } else {
        $(".forCreate").remove();
    }
}

I hope this approach will work in the current case. I wish you a great day!

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Nurali
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or