tr select applying only to sorted column

tr select applying only to sorted column

hillviewhillview Posts: 2Questions: 1Answers: 0

I'm borrowing code from row-selection example at
http://datatables.net/examples/api/select_single_row.html
without (conscious) change. I'm using the "display" class on the table.

Table appearance and control behaviors are as expected, except that when I select a row, only one cell in the row highlights: the cell in the column currently sorted. Viewing the page in a debugger confirms that the TD element getting the highlight is getting class "sorting_1", and the highlight color applied is #acbad4, from the rule at line 147 in jquery.dataTables.css. So, the observed behavior makes sense, but is not the behavior exhibited by the example linked above, in which the entire row highlights. Am I missing something obvious?

Thanks!

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    The "sorting-1" class applies to the currently sorted column. You should look for the "selected" class on the relevant row.

  • hillviewhillview Posts: 2Questions: 1Answers: 0

    Thanks, Tangerine--I guess I was unclear: the rule (in jquery.dataTables.css) applied to the "selected" class on tr was:

    table.dataTable.order-column tbody tr.selected > .sorting_1,
    table.dataTable.order-column tbody tr.selected > .sorting_2,
    table.dataTable.order-column tbody tr.selected > .sorting_3, 
    table.dataTable.display tbody tr.selected > .sorting_1,
    table.dataTable.display tbody tr.selected > .sorting_2,
    table.dataTable.display tbody tr.selected > .sorting_3 {
      background-color: #acbad4;
    }
    

    As you can see, these will apply the highlight to child elements with class "sorting_N"--in other words, only the td in sort-column. I fixed my problem by removing the "child with class 'sorting_N'" specification.

    In the end, my question came down to, "should the examples work 'out of the box', or might you need to alter the supplied css?" I didn't see any rule that would apply to the whole row without modification. Thanks again!

This discussion has been closed.