Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

How to stop a Datatable loop

$
0
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?


Viewing all articles
Browse latest Browse all 2364

Trending Articles