Different Template for Create and Edit?

5 posts, 0 answers
  1. Marcus
    Marcus avatar
    17 posts
    Member since:
    Jul 2012

    Posted 05 Oct 2012 Link to this post

    Is there a way to make something editable only on create and not on edit in the editor?

    To specify what I mean.

    I would like different rules for editable depending on whether you have add new or edit old post. Some key fields cannot be edited once you done the initial create.
  2. Nikhil
    Nikhil avatar
    5 posts
    Member since:
    Jan 2013

    Posted 14 Jan 2013 Link to this post

    Hey Marcus,

    Did you get your issue resolved? I am facing a similar issue and it would really be great if you could help me with it.
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 17 Jan 2013 Link to this post

    Hi Marcus,

     

    Basically you can use the Edit event to check if the current model is new  to find the required field editor and disable it - please check the example below:

    Define Edit event handler:

    .Events(e => e.Edit("onEdit"))

    onEdit function:
    function onEdit(e) {
        //Check if the record is new
        if (!e.model.isNew()) {
            popUp = e.container;
     
            //Find the field that must be disabled / hided
            fieldForDisable = popUp.find("#OrderDescription").prop('disabled', true);
        }
    }
    Kind regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. Klas
    Klas  avatar
    9 posts
    Member since:
    Aug 2012

    Posted 17 Jan 2013 Link to this post

    This is what I did but it would be nice in the future to be able to specify different templates for different modes, You can get alot of script otherwise.
  6. Nikhil
    Nikhil avatar
    5 posts
    Member since:
    Jan 2013

    Posted 17 Jan 2013 Link to this post

    Hi Vladimir,
    If you could please show me a code snippet to give the same functionality while using the grid in Inline editing mode, that would really be great.
Back to Top
UI for ASP.NET MVC is VS 2017 Ready