5
tôi sử dụng datatables (http://datatables.net/) để tạo bảng với JSON và tôi có một mã số:Nhận tên cột và hàng khi nhấp chuột vào tế bào trong datatables
<script type="text/javascript">
$(document).ready(function() {
$('#example').dataTable({
"ajax": "objects.txt",
"columns": [
{ "data": "name" },
{ "data": "position" },
{ "data": "office" },
{ "data": "extn" },
{ "data": "start_date" },
{ "data": "salary" }
]
});
});
</script>
<div class="container">
<table id="example" class="table table-striped table-bordered table-responsitive" cellspacing="0" width="100%">
<thead>
<tr>
<th>DAN</th>
<th>Aktivnost</th>
<th>Vreme</th>
<th>Rashodi</th>
<th>Prihodi</th>
<th>Beleske</th>
</tr>
</thead>
<tfoot>
<tr>
<th>DAN</th>
<th>Aktivnost</th>
<th>Vreme</th>
<th>Rashodi</th>
<th>Prihodi</th>
<th>Beleske</th>
</tr>
</tfoot>
</table>
</div>
Làm thế nào tôi có thể nhận được tên của hàng và tên của cột khi Tôi bấm vào một số tế bào? ALso cách nhận ID của hàng và ID cột khi nhấp vào một số ô trong bảng?
Cảm ơn, điều đó giúp tôi. Có cách nào khác ở đây không? –
Bạn nên giữ dữ liệu hàng bằng 'table.row (this) .data()' thay vì sẵn sàng cho DOM HTML – GETah