【发布时间】:2016-02-12 17:35:04
【问题描述】:
<thead>
<tr>
<th class="nosort">#</th>
<th>Name</th>
<th>Age</th>
<th>Location</th>
</tr>
</thead>
我有表,我正在使用 DataTables 对列进行排序。我有一个生成以下单元格的 while 循环。
# | Name | Age| Location
----------------------------
1 | Donald | 37 | Sidney
2 | Janice | 54 | London
3 | Alice | 44 | California
# 在循环中递增 i++。 DataTables 的“nosort”工作正常,我无法单击#。但是,例如,当我单击名称时,我想按名称对列进行排序,会发生以下情况。
# | Name | Age| Location
----------------------------
3 | Alice | 44 | California
1 | Donald | 37 | Sidney
2 | Janice | 54 | London
如您所见,# 根据名称“更改”。我希望修复使用 i++ 创建的 # 列,仅显示位置,这样当我按名称或年龄排序时它不会改变。我怎样才能做到这一点?
编辑:我当前的代码
$('#example').dataTable({
"paging": false,
"info": false,
"bFilter": false,
"order": [[ 1, "asc" ]],
"columnDefs": [{ "targets": 'nosort' }]
});
【问题讨论】:
-
您能分享一下您的尝试和遇到的问题吗?
标签: javascript php jquery sorting datatables