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

Using a DisplayTemplate

6 Answers 567 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mathias
Top achievements
Rank 1
Mathias asked on 26 Sep 2012, 07:27 AM
Hi everyone,

I have a grid in batch edit mode. When a cell gets in edit-mode it uses (if specified) its EditorTemplate. My question now is, if I am also able to somehow use a DisplayTemplate for the time the cells are in display-mode?

I have a property with an UIHint on the template I wanna use. The problem is, he only uses the EditorTemplate in edit-mode, but not the DisplayTemplate in display-mode. Is there any possibility of doing this? I know that I can use the .ClientTemplate property on the columns. But I wanna use intellisense, and I need to implement a hole bunch of JavaScript-Methods.

Hope there is a way and someone can show it to me :)

The funny thing is: when the grid is loaded he calls the DisplayTemplate once (actually the grid needs it! Without a DisplayTemplate with the same name as the EditorTemplate nothing works!)

best regards, Mathias

6 Answers, 1 is accepted

Sort by
0
michel
Top achievements
Rank 1
answered on 26 Aug 2013, 12:07 PM
*bump

We are having the same issue / question.
Everything is working well for the EditorTemplate, but kendo doesn't seem to pick up the DisplayTemplate.
Is there any known workaround for this problem ?

Kind regards,
0
Vladimir Iliev
Telerik team
answered on 29 Aug 2013, 07:49 AM
Hi Mathias,

 
Currently it's not possible to use "DisplayTemplate" for setting the display template of column in the Grid - you should use the ClientTemplate method instead. Also please note that you can call a JavaScript function using the "ClientTemplate" method in which to build the template:

columns.Bound(m => m.Price).ClientTemplate("#=customFunction(Price)#")

function customFunction(price) {
    var template = "";
 
    //execute your custom code to build the template and return it
 
    return template;
}
Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Dimitrij
Top achievements
Rank 1
answered on 17 Apr 2015, 09:10 AM

Is there any update on this? It's a bummer that I can't use ASP.NET MVC DisplayTemplates in a Kendo MVC Grid...

~ Dimitrij

0
Vladimir Iliev
Telerik team
answered on 17 Apr 2015, 01:45 PM
Hi Dimitrij,

Please note that the DisplayTemplates are supported in server binding mode. In Ajax binding mode the items are rendered on the client so a ClientTemplate should be used instead.

Regards,
Vladimir Iliev
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Dekel
Top achievements
Rank 1
answered on 23 Jun 2015, 06:12 AM

Hi,

I do noticed that Editor Templates are supported also in Ajax. so is there any plan to enable DisplayTemplates for the kendo controls?

 

Thanks

0
Vladimir Iliev
Telerik team
answered on 23 Jun 2015, 06:29 AM
Hello Dekel,


As I mention the display templates are server side markup which will work in server binding only. When the Grid use Ajax binding the editor template is bind on the client side where the server markup is already evaluated. That why if you need to render only the value without an editor you should use Kendo UI template syntax as demonstrated in the following example (the editor template is applicable for the Grid MVC wrapper as well):

Regards,
Vladimir Iliev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Mathias
Top achievements
Rank 1
Answers by
michel
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Dimitrij
Top achievements
Rank 1
Dekel
Top achievements
Rank 1
Share this question
or