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

Popup editor - different templates for different actions

5 Answers 147 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 04 Feb 2013, 02:36 PM

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

5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 06 Feb 2013, 10:50 AM
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!
0
Chrys
Top achievements
Rank 1
answered on 14 Feb 2013, 04:50 PM
So how would I access the different templates? would I just call them by name $('#templatename')?
0
Daniel
Telerik team
answered on 18 Feb 2013, 01:05 PM
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!
0
Chrys
Top achievements
Rank 1
answered on 18 Feb 2013, 02:57 PM
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
    }
}
0
Daniel
Telerik team
answered on 20 Feb 2013, 11:58 AM
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!
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Chrys
Top achievements
Rank 1
Share this question
or