3

I'm using

<th class="none"></th>

to hide the last column in datatable table. Datatable creates a button in the first column to show/hide this column in a child row. The colors of this button are set in responsive.bootstrap.min.css:

table.dataTable.dtr-inline.collapsed>tbody>tr>td:first-child:before{ background-color:#5d9cec }

I added a custom class the first column as to disable the button depending on data in row:

.not-active { pointer-events: none; cursor: default; }

I set the class via C# depending on the content of certain rows.

<tr><td class='<%# DisableLink(Eval("InvoiceDate").ToString()) %>'><%# Eval("InvoiceNumber")%></td>

All this is working as expected.

What I want to do now is set the background color of the button to grey when the td's class is set to .not-active, over writing background-color.

I have tried

.not-active > table.dataTable.dtr-inline.collapsed>tbody>tr>td:first-child:before{ background-color:#5d9cec }

and dozen of different combinations but can't seem to get the format correctly.

Any suggestions? Thanks!

Adding FSFiddle as requested: https://jsfiddle.net/yk06fbxa/3/

Diomedes
  • 634
  • 11
  • 24

1 Answers1

4

The CSS rule that sets the background-color is

table.dataTable.dtr-inline.collapsed tbody td:first-child:before, 
table.dataTable.dtr-inline.collapsed tbody th:first-child:before {
    ...
    background-color: #31b131;
}

To override this when the <td> has the class not-active you can modify it like that:

table.dataTable.dtr-inline.collapsed tbody td.not-active:first-child:before,
table.dataTable.dtr-inline.collapsed tbody th.not-active:first-child:before
{
    background-color:#dddddd;
}

See a demo here. I have set the td of the first row not to have the not-active class to make sure that it only works with the .not-active class.

Tasos K.
  • 7,979
  • 7
  • 39
  • 63