FixColumns: The fixed columns have a style that force background-color: white

FixColumns: The fixed columns have a style that force background-color: white

smelchersmelcher Posts: 40Questions: 11Answers: 0

When I create a datatable using the FixedColumns extension, the "fixed" columns all have a style that sets the background-color to white. See below:
table.dataTable tbody tr > .dtfc-fixed-left,
table.dataTable tbody tr > .dtfc-fixed-right {
z-index: 1;
background-color: white;
}

This causes me problems when I try to style the rows. Is there a way around this? I can change my SASS to handle this but its a fair amount of work/testing to get correct. And I would prefer to edit the standard datatables.css to make a customization.

Answers

  • kthorngrenkthorngren Posts: 20,777Questions: 26Answers: 4,857

    The simple answer is you can override the styling with your own, like this:
    https://live.datatables.net/kahikege/1/edit

    table.dataTable tbody tr.blue > .dtfc-fixed-left,
    table.dataTable tbody tr.blue > .dtfc-fixed-right {
      background-color: blue;
    }
    

    I added the classname blue to Ashton Cox row. If this doesn't help then please update the test case to show what you are trying to do so we can offer suggestions.

    Kevin

  • smelchersmelcher Posts: 40Questions: 11Answers: 0

    Thank you for the response. Yes, I agree I can do that but the problem is that I have many different styles for those cells. I would need to change all of my styles to include the dtfc-fixed-left class. I could do that but it would be very cumbersome and involve a ton of testing to make sure it works.

  • allanallan Posts: 62,448Questions: 1Answers: 10,251 Site admin

    The fixed cells have to have a background colour assigned to them, otherwise they are transparent and it looks awful when you start scrolling.

    I could make it a CSS variable - but you say you have a bunch of customisations. If so, I don't see anyway that you wouldn't need to make tweaks wherever you have a customisation? Unless I'm missing something. You can certainly make changes to the datatables.css file as you need.

    Allan

  • smelchersmelcher Posts: 40Questions: 11Answers: 0

    Ok, that makes sense. I will work through changing my SASS. Years ago, I would tweak the datatables.css but that got me into trouble with upgrades etc. Thanks for the response.

  • allanallan Posts: 62,448Questions: 1Answers: 10,251 Site admin

    What tweaks do you have? Could a CSS variable do it, or is it more complex than that?

    Allan

  • smelchersmelcher Posts: 40Questions: 11Answers: 0

    No, not terribly complex. This forced me to cleanup my SASS a bit. I got it all working fairly easily. Thanks again.

Sign In or Register to comment.