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

ColorPicker in Grid

2 Answers 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 29 Jan 2016, 02:24 PM
I've got a grid that I need to select a color criteria for the data.  I've created a Custom Model that uses the ColorPickerFor component and when in the color cell the colorPicker appears and I can select a color.  When I tab off of the cell the color value is displayed as "#fff111" or whatever color I selected.  I don't want to display the values in the grid like that but want to display them as a square color swatch showing the color even when the cell is not in edit mode.  How can you accomplish this.  I've been fiddling with ClientTemplate and I can't seem to get the background-color to work.

2 Answers, 1 is accepted

Sort by
0
Lee
Top achievements
Rank 1
answered on 29 Jan 2016, 02:44 PM

columns.Bound(c => c.GraphColor)
.HeaderTemplate("<a>Graph<br>Color</a>")
.ClientTemplate("<a style='background-color: #=GraphColor#; color: #=GraphColor#;'>' '</a> #=GraphColor#")
.Width(120);

 

The above code did the trick!!!  :)

0
Dimiter Madjarov
Telerik team
answered on 02 Feb 2016, 09:01 AM

Hello Lee,

Thanks for the update. Let us know if you experience further issues with the template.

I wish you a great day!

Regards,
Dimiter Madjarov
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
Lee
Top achievements
Rank 1
Answers by
Lee
Top achievements
Rank 1
Dimiter Madjarov
Telerik team
Share this question
or