How can I do cells with the same value red?

How can I do cells with the same value red?

huelohuelo Posts: 5Questions: 1Answers: 0

Hello, in the test mentioned below, those who write London in data[2] are in red. but what I want to do is have the columns with the same values ​​in data2 in red. for example, users with the same ip.

http://live.datatables.net/tohehohe/7103/edit

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736
    Answer ✓

    Are you saying that you want to check for duplicates in the column and mark those red?

    Kevin

  • huelohuelo Posts: 5Questions: 1Answers: 0

    yes

  • colincolin Posts: 15,112Questions: 1Answers: 2,583
    Answer ✓

    I've got an example that does just that: http://live.datatables.net/wisejipa/1/edit

    Colin

  • huelohuelo Posts: 5Questions: 1Answers: 0

    Thanks for your help colin. But when I get the table information from sql, I get the following warning.

    "DataTables warning: table id=dataTable - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3"

  • colincolin Posts: 15,112Questions: 1Answers: 2,583
    edited June 2021

    Have you followed the steps in the technical notes linked to in the error? That'll be the place to start,

    Colin

  • huelohuelo Posts: 5Questions: 1Answers: 0

    yes, retrieve: true, does not give an warning when I do it. but this time the same columns are not red.

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736

    Likely using retrieve: true is not the correct fix for your problem. Why are you initializing Datatatbles more than once? Please post your relevant JS code so we can take a look.

    Kevin

  • huelohuelo Posts: 5Questions: 1Answers: 0

    I solved the problem. It was working 2 times because there was another code.

    $(document).ready(function() { var table = $('#example').DataTable(); $('#example tbody') .on( 'mouseenter', 'td', function () { var colIdx = table.cell(this).index().column; $( table.cells().nodes() ).removeClass( 'highlight' ); $( table.column( colIdx ).nodes() ).addClass( 'highlight' ); } ); } );
Sign In or Register to comment.