Highlight selected row in a table CSS issue

Highlight selected row in a table but CSS does not get applied.

In a row action I used the code from Moshe question like this :

var item = params.item;

var list = item.list;

$.each( list.renderedItems,
    function(){
        this.element.removeClass( 'highlighted-row' );
    } );

item.element.addClass('highlighted-row');
console.log(item.element);

---------------------------------------------

I see element has desired class however my in-line CSS :

tr.nx-item.highlighted-row {
    background-color: lightblue;
}


the background-color does not render ??  any suggestions

The problem here is that your CSS is not selective enough to “beat” Skuid’s standard CSS rules. You’ll need to make it more selective than the next-most-selective CSS rule. In general, the most selective CSS rule wins out over less selective rules. A rule is made more selective by having more element or class selectors on it. Therefore, changing to the following should work:

table.nx-skootable-data tbody tr.highlighted-row td {   
   background-color: lightblue;
}

unfortunately that does not seem to have done the trick… I agree that it should have, and the console agrees with us… yet the row remains unchanged in the ui

It looks like your selector is targeting the element and not the elements inside the . Target the element with the background color and you should be fine. tags and backgrounds never seem to work. I’m sure there’s a pretty good explanation. I just don’t have it.

Jerry, did you use my CSS instead of yours?

yes c&p replaced it


Okay I believe you, but the screenshot you posted above makes it look like your previous CSS with tr.nx-item.highlighted-row is still in effect.

I guess I did not.. works now

thank you ..

A bit more explanation:

Applying a background color to the will work… ish. One problem with this approach, though, is that the background color of the row is completely hidden by the background color of the elements.

If you make sure to explicitly set the background color of the elements to transparent, then you’ll be able to see the background color of the .

There are a few other potential issues with setting the background color of the . In the end, it’s much easier to just set the background color of the elements as demonstrated by Zach.

how would this apply for mobile where you change the background of a selected item in a card?