gpt4 book ai didi

javascript - Bootstrap 表过滤不起作用

转载 作者:太空狗 更新时间:2023-10-29 14:10:44 28 4
gpt4 key购买 nike

我想为 Bootstrap 表添加过滤。我添加了两个属性,我在下面的代码中将它们四舍五入。为什么它不起作用?我还应该做什么?

    <table id="clients-table" class="table table-striped table-condensed" 
data-toggle="table" data-show-toggle="true" data-cache="false" data-show-refresh="true"
data-url="../data.json"
//-----------------------------------------------------
data-filter-control="true"
//-----------------------------------------------------
data-side-pagination="server"
data-search="true" data-sort-name="Id" data-sort-order="desc"
data-pagination="true" data-page-size="25">
<thead>
<tr>
<th data-field="Id" data-sortable="true">Id</th>
<th data-field="Email" data-sortable="true">E-Mail</th>
<th data-field="CompanyName" data-sortable="true">Firma</th>
<th data-field="Name" data-sortable="true">Imię i nazwisko</th>
<th data-field="Phone" data-sortable="true">Nr telefonu</th>
<th data-field="UserType" data-sortable="true">Typ</th>
<th data-field="PricingType" data-sortable="true"
//----------------------------------------------------------
data-filter-control="select"
//----------------------------------------------------------
>Cennik</th>
<th data-field="LastSynchronizationOn" data-sortable="true">Synchronizacja</th>
</tr>
</thead>
</table>

我还有一些 JS 脚本来处理来自服务器的错误

   $('#clients-table').bootstrapTable({
onLoadError: function (status) {
SetErrorMessage('Wystąpił błąd serwera podczas wczytywania danych. Skontaktuj się z administratorem.');
}
});

我也附上了这个脚本

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/bootstrap-table.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/locale/bootstrap-table-pl-PL.min.js"></script>

<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/extensions/filter/bootstrap-table-filter.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/extensions/filter-control/bootstrap-table-filter-control.min.js"></script>

最佳答案

如果你想用 select 过滤,我认为它可行:

<!DOCTYPE html>
<html>
<head>
<title></title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" type="text/css" href="http://bootstrap-table.wenzhixin.net.cn/assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/bootstrap-table.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

<script src="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/bootstrap-table.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/locale/bootstrap-table-pl-PL.min.js"></script>

<script src="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/extensions/filter/bootstrap-table-filter.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/extensions/filter-control/bootstrap-table-filter-control.min.js"></script>

</head>
<body>
<table id="clients-table" class="table table-striped table-condensed"
data-toggle="table"
data-show-toggle="true"
data-cache="false"
data-show-refresh="true"
data-url="data.json"
data-filter-control="true"
data-side-pagination="server"
data-search="true"
data-sort-name="Id"
data-sort-order="desc"
data-pagination="true"
data-page-size="25">
<thead>
<tr>
<th data-field="Id" data-sortable="true">Id</th>
<th data-field="Email" data-sortable="true">E-Mail</th>
<th data-field="PricingType" data-sortable="true" data-filter-control="select">Cennik</th>
<th data-field="LastSynchronizationOn" data-sortable="true">Synchronizacja</th>
</tr>
</thead>
</table>

<script>
var $table = $('#clients-table');

$table.bootstrapTable();
</script>
</body>
</html>

还有你的 data.json:

{
"total": 800,
"rows": [
{
"Id": 1,
"Email": "email@gmail.com",
"PricingType": "Value 1",
"LastSynchronizationOn": "date"
},
{
"Id": 2,
"Email": "other@gmail.com",
"PricingType": "Value 2",
"LastSynchronizationOn": "date"
}
]
}

关于javascript - Bootstrap 表过滤不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33670454/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com