Identify and add style class for specific column with duplicated values

Identify and add style class for specific column with duplicated values

hashsazhashsaz Posts: 1Questions: 1Answers: 0
edited May 2020 in Free community support

Hi, I am not sure if this question been asked before but I couldn't find exact answer for what I need.

I am working with a subscription system where we will giving out FREE voucher to subscriber, but we found out there's many subscribers are under the same IP address. We don't mind to collect those data but i would like to highlight the specific row when duplicate data found something like:

<tr class="duplicateclass">
<td>Aaron</td>
<td>192.111.111.111</td>
</tr>
<tr class="">
<td>Becky</td>
<td>111.222.222.111</td>
</tr>
<tr class="duplicateclass">
<td>Catherine</td>
<td>192.111.111.111</td>
</tr>

then underneath the table, it shall display something like:

192.111.111.111 : Repeat 2 times

which easier for me to search them out.

Any ideas??

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    You could get the data with column().data() and use sort() - so something like

    table.column(1).sort().toArray()
    

    Iterate through, and if the current value is the same as the previous, flag it,

    Colin

This discussion has been closed.