bootstrap-table-filter-控制选项排序

bootstrap-table-filter-control options sorting

使用带有过滤器控制扩展的 whenzhixin 的 Boostrap table。 http://bootstrap-table.wenzhixin.net.cn/extensions/#table-filter-control

我希望 select 中显示的选项按数字顺序排序。

代码位于:https://jsfiddle.net/yd75psoc/4

<script type="text/javascript" src="https://unpkg.com/jquery@3.3.1/dist/jquery.min.js"></script>

<script src="https://unpkg.com/bootstrap-table@1.14.2/dist/bootstrap-table.min.js"></script>
<script src="https://unpkg.com/bootstrap-table@1.14.2/dist/extensions/filter-control/bootstrap-table-filter-control.min.js"></script>

<table
    id="table"
    data-filter-control="true"
    data-filter-show-clear="true">
    <thead>
        <tr>
            <th data-field="id">ID</th>
            <th data-field="name">Item Name</th>
            <th data-field="price" data-filter-control="select">Item Price</th>
        </tr>
    </thead>
</table>

<script>
    var $table = $('#table')

    $(function() {
        var data = [
            {
                'id': 0,
                'name': 'Item 0',
                'price': ''
            },
            {
                'id': 1,
                'name': 'Item 1',
                'price': ''
            },
            {
                'id': 2,
                'name': 'Item 2',
                'price': ''
            }
        ]
        $table.bootstrapTable({data: data})
    })
</script>

您会看到选项按以下顺序显示:1、10、2。 current behaviour

我需要这些值按数字顺序显示:1、2、10。

这是您使用的 filter-control 版本中的错误。

我已经编辑了您的代码,它可以与我正在使用的 filter-control 版本一起使用。

已编辑 fiddle:https://jsfiddle.net/eitanmg/0y3tp4n7/1/

filter-control 我正在使用的版本(并解决了你的问题):

https://raw.githubusercontent.com/eitanmg/bootstrap-table-filter-control/master/bootstrap-table-filter-control.js

只需将此库替换为您的库即可。