5
我用用JSON创建表数据表(http://datatables.net/),我有一个代码:获取行和列名时,单击单元格中的数据表
<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>
我怎样才能得到列时的行名的名称我点击某个单元格? 当点击表格中的某个单元格时,如何获取行的ID和列的ID?
谢谢,那帮助我。这里还有其他的方法吗? – 2014-10-30 14:09:53
您应该通过'table.row(this).data()'获取行数据,而不是准备好HTML DOM – GETah 2016-10-21 21:36:17