How to use Different Templates For Edit and Create Operations

2 posts, 0 answers
  1. Nurali
    Nurali avatar
    16 posts
    Member since:
    Oct 2010

    Posted 04 Dec 2013 Link to this post

    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?
  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2272 posts

    Posted 04 Dec 2013 Link to this post

    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!
Back to Top