Hover is not highlighting rows
Hover is not highlighting rows
Mwhite007
Posts: 20Questions: 6Answers: 0
in DataTables 2
in order to control color scheme on my table, you gave me a small function which works great mostly:
/* ANY ADDED ROW SHOULD HAVE THE 'DATA' CLASS ADDED */
createdRow: function ( tr ) {
$(tr).addClass('data');
},
but i think this kills the hover/highlight function on the dataTable tbody rows. if i remove the createdRow function the highlighting works on hover but i lose the css from the color scheme i have
This question has an accepted answers - jump to answer
Answers
this is the css for the data class
i'm using Bootstrap 5.3 but adding the class table-hover doesn't seem to have any effect
https://getbootstrap.com/docs/5.3/content/tables/#hoverable-rows
here are the global variables:
AFAIK adding
table-hoverclass should enable hovering on the BS5 Datatable. I placed your code snippets in this test case:https://live.datatables.net/totagoxo/1/edit
The CSS you supplied is using the selector
.data td. This does not apply to thedataclass assigned to the rows. Also the selector won't work and should betd .data.Please update my test case to show the issue you are having so we can help debug. Or provide a link to a test case replicating the issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
I updated my test case with the CSS selector and it seems to work:
Updated test case:
https://live.datatables.net/loraloni/1/edit
If you still need help please provide a link to a test case replicating the issue.
Kevin
with your test case I was able to find that i was missing the "table" class on the table tag. When i added that i lost my css color scheme (background-color was being overwritten) so i had to update the css by adding !important .
the old line:
the new line: