How to stop a Datatable loop
How to stop a Datatable loop
HieuHoang
Posts: 6Questions: 3Answers: 0
I'm using rows().every of Datatable to compare a value in each rows. But I have so many rows, and I want to break the loop when find out the row include value I want.
I have tried as example below but it is not work:
Example 1: This example is not show any error
table.rows().every(function(rowIdx, tableLoop, rowLoop){
if(this.nodes().to$().attr('id') == id){
console.log('OK')
return false
}
})
Example 2: This example show a error when load the page Uncaught SyntaxError: Illegal break statement
table.rows().every(function(rowIdx, tableLoop, rowLoop){
if(this.nodes().to$().attr('id') == id){
console.log('OK')
break
}
})
So how can I do that?
Answers
This thread is asking the same question.
Kevin
Thank Kevin
Perhaps a better option in this case is to use a function selector:
Allan