【发布时间】:2020-07-15 06:08:24
【问题描述】:
我在我的管理页面中使用 Boostrap 表来描述我的数据库中的表。我将一个数组保存到 json 文件中,然后进入表格并使用以下代码显示它:
<div class=\"row\">
<div class=\"col-lg-12\">
<div class=\"panel panel-default\">
<div class=\"panel-heading\"> <a href='record_show.php?tselect=blog&typerec=newblog' class='btn btn-success'>Добавить запись</a></div>
<table data-toggle=\"table\" data-url=\"tables/data4.json\" data-sort-name=\"id\" data-sort-order=\"desc\" data-show-refresh=\"true\" data-show-toggle=\"true\" data-show-columns=\"true\" data-search=\"true\" data-select-item-name=\"toolbar1\" data-pagination=\"true\" >
<thead>
<tr>
<th data-field=\"id\" data-sortable=\"true\">ID</th>
<th data-field=\"header\" data-sortable=\"true\" >Заголовок</th>
<th data-field=\"intro\" data-sortable=\"true\" >Введение</th>
<th data-field=\"status\" data-sortable=\"true\" >Статус</th>
<th data-field=\"seo\" data-sortable=\"true\" >Сео</th>
<th data-field=\"type\" data-sortable=\"true\" >Тип</th>
<th data-field=\"date\" data-sortable=\"true\" >Дата</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
问题在于 Bootstrap 表仅按字母数字排序,即 (1,11,12,2,21,3) 等。您是否有过将 Bootstrap 表强制转换为数字排序的经验,即 (1,2, 3,11,12,21)?
【问题讨论】:
-
为什么不向表格提供排序后的数据?
-
因为我使用了 Bootstrap 表中的排序功能,例如 sort desc/asc
标签: javascript bootstrap-4 bootstrap-table