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

How to render clienttemplate with color from data object

1 Answer 673 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Roel
Top achievements
Rank 1
Iron
Veteran
Roel asked on 08 Jan 2021, 02:04 PM

Hi,

I like to render a column in the MVC grid with a dynamically rendered field with a color hex. This is in a subgrid wich is generated like below:

.ClientDetailTemplateId("templateSubTasks")

I know that when using a hashtag in a template grid you have to proceed it with two \ I also know that when using a hashtag for example a color hex, you have to proceed it with 4 \. But what when the color hex is loaded with a value from the data property like  #= data.TaskLabel?data.TaskLabel.Color:'' #

Her you can see the column I create in the parent grid. This has to be adjusted for use in a subgrid as a template.

columns.Bound(c => c.TaskLabel).Title(Order.clmLabel).ClientTemplate("<div style='border-radius: 3px; display:inline; width: 8px; height: 18px; background-color: #= data.TaskLabel?data.TaskLabel.Color:'' #'>&nbsp; </div><span style='margin-left:10px'> #= data.TaskLabel?data.TaskLabel.Name:'' #</span>").Width(100).Encoded(false).EditorTemplateName("GridDropdownEditorLabel");

I didn't succeed with adding \\\\ to the property data.TaskLabel.Color.

Do you have any idea?

Kind regards,

Roel Alblas

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 12 Jan 2021, 10:48 AM

Hello, Roel,

Could you please review the forum threads below that discuss the same topic? Maybe they will help you discover what is causing the problem at your end.

If they do not resolve the problem, please provide a small runnable example where I can observe it. I will debug it and try to find the root of the issue.

Looking forward to your reply.

Regards,
Martin
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Roel
Top achievements
Rank 1
Iron
Veteran
Answers by
Martin
Telerik team
Share this question
or