Highlight Row (with Column Sorting Enabled)
Highlight Row (with Column Sorting Enabled)
Hello All,
I am trying to get row highlighting to work and although I can get close to a solution, I cant seem to get it to work.
I have seen this example, http://www.datatables.net/examples/api/highlight.html, but I only want to highlight rows, not columns.
What I have done so far is add these type style classes:
[code]tr.even:hover {
background-color: #ffff99;
}
tr.odd:hover {
background-color: #ffff99;
}[/code]
At first glance this works great and highlights the row on hover.
The problem is that if I then sort a column, the sorted column TDs take on a new style class (sorting_1). So, in my 4 column table, when I mouse over a row, only 3 of the columns highlight, which looks silly.
I tried to get crafty (with tried being the key word!), and created these style classes:
[code]tr.odd td.sorting_1:hover {
background-color: #ffff99;
}
tr.even td.sorting_1:hover {
background-color: #ffff99;
}[/code]
This sort of gets me closer to a solution, but not exactly. Now, when a column is sorted, if I mouse-over the sorted TD, then the whole row highlights. But, if I put my cursor in one of the other columns, it no longer highlights that sorted TD and Im back to the whole 3 out of 4 columns in my row highlight issue.
I realize this is because I have the hover tag on the TD, which is why it only works if the mouse is over that TD.
Im sure there is a way to get this to work, but Im stumped.
Any ideas? Thanks in advance!
I am trying to get row highlighting to work and although I can get close to a solution, I cant seem to get it to work.
I have seen this example, http://www.datatables.net/examples/api/highlight.html, but I only want to highlight rows, not columns.
What I have done so far is add these type style classes:
[code]tr.even:hover {
background-color: #ffff99;
}
tr.odd:hover {
background-color: #ffff99;
}[/code]
At first glance this works great and highlights the row on hover.
The problem is that if I then sort a column, the sorted column TDs take on a new style class (sorting_1). So, in my 4 column table, when I mouse over a row, only 3 of the columns highlight, which looks silly.
I tried to get crafty (with tried being the key word!), and created these style classes:
[code]tr.odd td.sorting_1:hover {
background-color: #ffff99;
}
tr.even td.sorting_1:hover {
background-color: #ffff99;
}[/code]
This sort of gets me closer to a solution, but not exactly. Now, when a column is sorted, if I mouse-over the sorted TD, then the whole row highlights. But, if I put my cursor in one of the other columns, it no longer highlights that sorted TD and Im back to the whole 3 out of 4 columns in my row highlight issue.
I realize this is because I have the hover tag on the TD, which is why it only works if the mouse is over that TD.
Im sure there is a way to get this to work, but Im stumped.
Any ideas? Thanks in advance!
This discussion has been closed.
Replies
[code]
#example tr.even:hover {
background-color: #ECFFB3;
}
#example tr.even:hover td.sorting_1 {
background-color: #DDFF75;
}
#example tr.odd:hover {
background-color: #E6FF99;
}
#example tr.odd:hover td.sorting_1 {
background-color: #D6FF5C;
}
[/code]
Regards,
Allan
I only get highlighting on a cell (not a row), and only after I've specifically clicked to sort that row. Otherwise, nothing.
If it helps, my table sits in a div that is hidden at first. When a user clicks a button, the div becomes visible, and I use ajax to get all the data to generate the table.
Thanks for any help you can provide.
[code]
#example tr.even:hover {
background-color: #ECFFB3;
}
#example tr.even:hover td.sorting_1 {
background-color: #DDFF75;
}
#example tr.odd:hover {
background-color: #E6FF99;
}
#example tr.odd:hover td.sorting_1 {
background-color: #D6FF5C;
}
[/code]