CSS: Table Cells: Background Color

  • 1
  • Question
  • Updated 3 years ago
I'd like to adjust the color of 2 different "columns" in a table using CSS.  The table has 8 or so columns.  How do I identify only those 2 columns?
Photo of Scott

Scott

  • 2,722 Points 2k badge 2x thumb

Posted 4 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
For those two columns, use template fields, allow HTML and set the class in the HTML. Then set CSS as per the class you named in the HTML of the template field.
Photo of Charlie M

Charlie M

  • 102 Points 100 badge 2x thumb
Hi Scott,

Create a Javascript snippet and add that snippet to that field

You can try with this snippet

var $ = skuid.$;var field = arguments[0];
var value = arguments[1];

switch( field.mode ){
    case 'edit':
        skuid.ui.fieldRenderers[field.metadata.displaytype].edit( field, value );
        break;

    case 'read':
    case 'readonly':
        var cellElem = field.element;
        var iconElem =
            $( '<div>' )
                .css('background-color', 'salmon');
                .appendTo( cellElem );
}

-cheers,
Charles M