I am using DataTable plugin for generating data from database using javascript. I am showing that data in table tag like
我使用DataTable插件使用javascript从数据库生成数据。我在表标签中显示数据
foreach ($data as $row) {
$total += $row->price;
?>
<tr>
<td><?php echo $row->id; ?></td>
<td><?php echo $row->created_date; ?></td>
<td><?php echo $row->vender; ?></td>
<td><?php echo $row->usertype; ?></td>
<td><?php echo $row->price; ?></td>
<td><?php echo $row->payment_type; ?></td>
<td><?php echo $row->vender_inv; ?></td>
<td><?php echo $row->note; ?></td>
<td><a class="example-image-link" href="<?php echo $row->image; ?>" data-lightbox="example-1"><img style="width:100px !important; height:100px !important;" class="example-image" src="<?php echo $row->image; ?>" alt="image-1" /></a>
</td>
</tr>
<?php
}
Now I want to retrieve individual rows from it, I am trying to do it like this
现在我想从中检索单个行,我试图这样做
var table = $('#myTable').DataTable();
table.column(4).eq(0).each( function ( colIdx ) {
console.log( colIdx, table.column( colIdx ).search() );
} );
1 个解决方案
#1
0
Look at the rows() API: https://datatables.net/reference/api/rows().every()
查看rows()API:https://datatables.net/reference/api/rows()。every()
table.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var data = this.data();
// ... do something with data(), or this.node(), etc
} );
#1
0
Look at the rows() API: https://datatables.net/reference/api/rows().every()
查看rows()API:https://datatables.net/reference/api/rows()。every()
table.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var data = this.data();
// ... do something with data(), or this.node(), etc
} );