Hoppa till huvudinnehållet

How to add a color swatch/color picker in Display Form

Kommentarer

5 kommentarer

  • Berend Veldkamp
    Here's something that just came to mind. It will only work if the number of colors is limited.

     

    Add a combobox to the displayform, and add the colors you want to it. Then, add this to the custom styles file (Resources\Styles\Custom\DEVICE.css) option:nth-child(1) { background-color: red; } option:nth-child(2) { background-color: green; } option:nth-child(3) { background-color: blue; }

     

    You will need to make the selectors a bit more specific, this example will work for any combobox/listbox on the page, maybe you could use the id of the SELECT tag, e.g. #formitem-avwfX2rt > option:nth-child(1) but I'm not sure if that's a static value.
    0
  • Zack Robison
    Clever move, Berend.  I'd like to add that you can use hexadecimal representations here in addition to the css named colors (https://www.w3schools.com/cssref/css_colors.asp) ie: option:nth-child(0) { background-color: #7D64C8; }

     

     
    0
  • Permanently deleted user
    So, if I understand you correctly, the entire 'row' of the combobox/listbox will be the color specified in the css file?  I suppose that would work but this would just be for visual purposes only, kind of like a legend.  I'm currently adding the unique values to a Markdown item in the form (image below).  Is there any way to add a color swatch next to the line item (next to 4.00 and 5.00)?

     

    User-added image

     

     
    0
  • Berend Veldkamp
    I haven't found a way to use colors in a markdown item, but I do know that the Description for a Group item recognizes most html tags. You could for instance use a table where the background color for the first column (TD) is set.
    0
  • Permanently deleted user
    Hey Berend,

     

    Thanks for the input, I'll give that a try.
    0

Du måste logga in om du vill lämna en kommentar.