Get column name from clicked row
Get column name from clicked row
Ludde
Posts: 43Questions: 11Answers: 0
Hello,
I use the code below to toggle the color of the row on click. I would like to filter out two columns that I do not want to change the color when the row is clicked. What is the best way to do that? Can I get the column name from the click?
$('#idTable tbody').on('click', 'tr', function (e) {
$(this).toggleClass('selected');
});
Cheers L
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
This question has an accepted answers - jump to answer
Answers
You can inspect the rows that are selected to see what styling is set. You might find something like this for each
td
in the selected row:Keep looking and you will see that it overrides this:
So you will want to override this for the columns you don't want to highlight. Also you will find that the text color is set to white so you will want to override that and set it to the normal text color that was overridden. See this default styled Datatables to see how the above can be overriden:
http://live.datatables.net/jiquxawa/1/edit
You will probably need to change the selector used to something like this to get the column clicked using the
column-selector
oftd
:Kevin
Thanks again kthorngren! You pointed me again in the correct direction! Super thanks!