我在用

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

隐藏数据表中的最后一列。Datatable在第一列中创建一个按钮,以在子行中显示/隐藏此列。此按钮的颜色在responsive.bootstrap.min.css中设置:
table.dataTable.dtr-inline.collapsed>tbody>tr>td:first-child:before{ background-color:#5d9cec }

我在第一列添加了一个自定义类,以便根据行中的数据禁用按钮:
.not-active { pointer-events: none; cursor: default; }

根据特定行的内容,我通过C#设置类。
<tr><td class='<%# DisableLink(Eval("InvoiceDate").ToString()) %>'><%# Eval("InvoiceNumber")%></td>

所有这些都按预期进行。
我现在要做的是,当td的类设置为时,将按钮的背景色设置为灰色。不活动,过度写入背景色。
我试过了
.not-active > table.dataTable.dtr-inline.collapsed>tbody>tr>td:first-child:before{ background-color:#5d9cec }

和十几种不同的组合,但似乎无法得到正确的格式。
有什么建议吗?谢谢!
按要求添加FSFiddle:https://jsfiddle.net/yk06fbxa/3/

最佳答案

设置背景颜色的CSS规则是

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

若要在<td>具有类not-active时重写此项,可以对其进行如下修改:
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;
}

观看演示here。我已经将第一行的td设置为没有not-active类,以确保它只与.not-active类一起工作。

10-05 20:57
查看更多