jquery datatable行背景颜色在排序列中未更改
我使用的是jquery数据表,我希望背景颜色根据悬停条件进行更改。排序的行没有您在我的图像上看到的背景颜色 这是我的情况jquery datatable行背景颜色在排序列中未更改,jquery,css,datatables,Jquery,Css,Datatables,我使用的是jquery数据表,我希望背景颜色根据悬停条件进行更改。排序的行没有您在我的图像上看到的背景颜色 这是我的情况 "rowCallback": function (row, data, index) { if (data.componente.default_ubicacion.ubicacion_id === 0) { $(row).css("background-color&quo
"rowCallback": function (row, data, index) {
if (data.componente.default_ubicacion.ubicacion_id === 0) {
$(row).css("background-color", "rgb(225, 27, 27, 100%)");
$(row).css("color", "white");
$(row).addClass("group");
}
},
这就是导致问题的css
table.dataTable.display tbody tr.odd > .sorting_1, table.dataTable.order-column.stripe tbody tr.odd > .sorting_1 {
background-color: #f1f1f1;
}
table.dataTable.display tbody tr.even > .sorting_1, table.dataTable.order-column.stripe tbody tr.even > .sorting_1 {
background-color: #fafafa;
}
如何解决此问题非常感谢您的帮助。尝试以下方法:
"rowCallback": function (row, data, index) {
if (data.componente.default_ubicacion.ubicacion_id === 0) {
$(row).css("background-color", "rgb(225, 27, 27, 100%)");
$(row).css("color", "white");
$(row).addClass("yourClassName");
}
}
然后在CSS文件中包含以下内容:
table.dataTable.display tbody tr.yourClassName.even > .sorting_1, table.dataTable.order-column.stripe tbody tr.yourClassName.even > .sorting_1 {
background-color: transparent;
}
table.dataTable.display tbody tr.yourClassName.odd > .sorting_1, table.dataTable.order-column.stripe tbody tr.yourClassName.odd > .sorting_1 {
background-color: transparent;
}
显然我不知道你的数据,但我为你准备了一个小例子:
var-oTable=$('#tableName').DataTable({
rowCallback:函数(行、数据、索引){
如果(数据[0]==2){
$(行).css('background-color','rgb(225,27,27,100%))
.css('颜色','白色')
.addClass(“您的类名”);
}
}
});代码>
table.dataTable.display tbody tr.yourClassName.偶>.sorting_1,table.dataTable.order-column.stripe tbody tr.yourClassName.偶>.sorting_1{
背景色:透明;
}
table.dataTable.display tbody tr.yourClassName.odd>.sorting_1,table.dataTable.order-column.stripe tbody tr.yourClassName.odd>.sorting_1{
背景色:透明;
}
等级
国家
代码
全部的
啤酒
葡萄酒
精神
其他
分数
1.
爱沙尼亚
EE
14.97
5.87
1.65
5.64
1.81
3-中等风险
2.
白俄罗斯
通过
14.44
2.5
0.75
6.73
4.46
4-非常危险