ColorPicker in Grid

3 posts, 0 answers
  1. Lee
    Lee avatar
    20 posts
    Member since:
    Jun 2014

    Posted 29 Jan Link to this post

    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. Lee
    Lee avatar
    20 posts
    Member since:
    Jun 2014

    Posted 29 Jan Link to this post

    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!!!  :)

  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2159 posts

    Posted 02 Feb Link to this post

    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
Back to Top