Table row background based on first cell style

I found myself in the situation where I needed a table row to have a certain background color to be quickly identified. However, display rules are applied by cell, which means that you shoud set the same display rule for each column of the table. For very big tables this is a pain so I came out with this simple trick. Basically I am applying the display rule on the first column and then through javascript I am replicating the style in the rest of the columns of that row.

This is my code:

  $(document).on('knack-view-render.view_872', function(event, view, record) {
$('table > tbody > tr').find('td:first').each(function() {
$(this).parent().attr('style',$(this).attr('style'));
});
});
3 Likes

Could you please explain the code a little so we can modify to work on our table view? Greatly appreciated!
Kyle

This just saved me so much time! Thank you @DavideAgno21569 and @CarlHolmes for the video! Table Backgrounds - Knack Database - YouTube

3 Likes