FixedColumns row class ignored

FixedColumns row class ignored

edwardiv1edwardiv1 Posts: 13Questions: 3Answers: 0

When using FixedColumns and specifying the first 2 rows as fixed, the row class is not applied to the fixed columns.

fixedColumns: {
left: 2
},
fixedHeader: {
  header: true,
},
scrollCollapse: true,
scrollX: true,
...

<tr class="danger"><td>...</td></tr>

The "danger" class is applied to the entire row, except for the columns that are fixed.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,441Questions: 1Answers: 10,459 Site admin

    Hi,

    We need to assign a background colour to the fixed cells, otherwise they might be transparent, and it looks horrible! As such, any assignment you make to override that colour needs to have a higher priority in CSS - !important might help in this case: https://live.datatables.net/gehihuge/1/edit .

    Allan

  • edwardiv1edwardiv1 Posts: 13Questions: 3Answers: 0

    Hi Allan,
    Thanks for explaining.

    Not sure how practical it is for me to add !important - the classes are defined in standard Bootstrap CSS - https://getbootstrap.com/docs/3.4/css/#tables-contextual-classes

    It's not a huge priority, but would certainly make it look much better if it could be addressed.

  • allanallan Posts: 63,441Questions: 1Answers: 10,459 Site admin

    I'm not sure I can address it. The CSS stylings for the background colour you want need to be made more specific to override the FixedColumns ones, which have to be there as explained.

    What class is it you are adding? Perhaps you just need to create a custom style with that colour and make it a higher priority.

    Allan

  • edwardiv1edwardiv1 Posts: 13Questions: 3Answers: 0

    Yes, I see what you mean now about the transparent background and display issues.
    I wonder if it's possible to add the white background in the fixed columns only if an existing background color is not already set - perhaps using javascript to check the cell style.

  • allanallan Posts: 63,441Questions: 1Answers: 10,459 Site admin
    Answer ✓

    I'm not actually sure if that is possible. I suspect it would also be slow since it might need to query each cell, since a background might be assigned to some cells and not others.

    It would be much easier to just add the following to your site's CSS:

    .danger td {
      background: red !important;
    }
    

    Allan

  • edwardiv1edwardiv1 Posts: 13Questions: 3Answers: 0

    Thanks, Allan. Great product by the way!

  • allanallan Posts: 63,441Questions: 1Answers: 10,459 Site admin

    Thank you :)

Sign In or Register to comment.