Popup editor - different templates for different actions

6 posts, 0 answers
  1. John
    John avatar
    23 posts
    Member since:
    Nov 2012

    Posted 04 Feb 2013 Link to this post


    Hi,

    I'm have a Grid of users (Ajax datasource) with CRUD commands.

    Is it possible to specify different templates for each command (one template for create, one for edit etc....?

    Regards
  2. Daniel
    Admin
    Daniel avatar
    2219 posts

    Posted 06 Feb 2013 Link to this post

    Hello John,

    Only one editor template is supported. If you need to show different fields then I can suggest to use the Grid edit event to find and hide the needed ones for the mode. The mode can be determined through the model isNew method e.g.

    function edit(e) { 
        if (e.model.isNew()) {//create
     
        }          
        else {//edit
             
        }
    }
    Kind regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Chrys
    Chrys avatar
    45 posts
    Member since:
    Feb 2013

    Posted 14 Feb 2013 Link to this post

    So how would I access the different templates? would I just call them by name $('#templatename')?
  4. Daniel
    Admin
    Daniel avatar
    2219 posts

    Posted 18 Feb 2013 Link to this post

    Hello Chrys,

    I am not sure if I understand correctly your question. Could you clarify a bit? As general information I can say that the editor cannot be added in the edit event because it is called after the edit container has already been bound. Instead when using the wrappers, the editors for both cases should be added and then hidden or removed in the aforementioned event. 

    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. Chrys
    Chrys avatar
    45 posts
    Member since:
    Feb 2013

    Posted 18 Feb 2013 Link to this post

    Now that I understand the answer better. How would would I specify which field were hidden or not in the function you have provided?
    function edit(e) { 
        if (e.model.isNew()) {//create
                show username from model
        show firstname from model
        show lastname from model 
                show email from model
        }          
        else {//edit
             show username from model
    show email from model
        }
    }
  6. Daniel
    Admin
    Daniel avatar
    2219 posts

    Posted 20 Feb 2013 Link to this post

    Hello Chrys,

    For this scenario it would be easiest to leave all inputs visible in the template and then hide the unneeded for the operation e.g.

    function edit(e) {    
        if(!e.model.isNew()) {
            $("#firstname").hide();
            $("#lastname ").hide();        
        }
    }
    You could also wrap the fields that should not be visible in a container and hide it.
    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top