Highlight the ENTIRE row....

Highlight the ENTIRE row....

gmarshall56gmarshall56 Posts: 15Questions: 6Answers: 0

I know this question has been asked several times in this forum as well as other technical web sites however I have yet to find a solution to a simple situation.

You had stated in the past to use the function fnSelectRow to highlight an entire row of a dataTable. I would like to do just that. Upon initialization, or immediately thereafter but before displaying the web page, I would like to check a value in a column and determine if I want that entire row highlighted, not just a specific column.

Please see my test case: http://live.datatables.net/soyikos/8/edit where I employed fnRowCallback just to get myself started. This function does not highlight the entire row; it leaves out highlighting the first column.

Thank you again for your time. Gary

Answers

  • kqueekqueekqueekquee Posts: 40Questions: 1Answers: 0

    i make this
    http://live.datatables.net/soyikos/11/edit

            "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
                if ( aData[0] == "22" )  {                  
                    $('td', nRow).css({"background-color": "#F8E0E6" })
                }
             }
    

    Christian/France

  • gmarshall56gmarshall56 Posts: 15Questions: 6Answers: 0

    Great! Thank you.

    Instead of setting the background-color there in the fnRowCallBack function, what would the syntax be in the fnRowCallBack function to reference a css rule that would allready be defined?

    Thank you again kind sir.

  • gmarshall56gmarshall56 Posts: 15Questions: 6Answers: 0

    Christian/France's solution worked great. It highlighted the entire row for me. Thank you again.

    Upon further testing I found that when I select another row, that row gets highlighted, as is required, but the row that was highlighted when the table is first displayed does not become un-highlighted. I searched through the site and found a solution using tableTools but I could not get that to work. See:

    http://live.datatables.net/soyikos/13/edit

    Anyway, tableTools is not a valid solution because we do not need nor want the features of tableTools to appear on the web page. So, what can you recommend to allow for a particular row to be highlighted when the table first renders and then will become un-selected when the user selects a different row?

    As always, thank you. Gary

This discussion has been closed.