如何解决如何清理高级搜索表单和刷新数据
下午好!我是新手。我使用 bootstrap-table 项目和它的工具栏扩展。工具栏允许您使用高级搜索对数据进行排序。在 input 中输入数据时,advancedSearch 起作用。排序在模式窗口中打开。我想创建一个自定义按钮来清除表单并更新数据(清除过滤器)。在此之前,我创建了一个自定义刷新按钮,但它不适用于高级搜索。
<table id="table-users" >
<thead>
<tr>
<th data-field="id" data-sortable="true">ID</th>
<th data-field="username" data-sortable="true">Имя</th>
<th data-field="fio" data-sortable="true">ФИО</th>
<th data-field="company" data-sortable="true">Организация</th>
<th data-field="department" data-sortable="true">Департамент</th>
<th data-field="dolg" data-sortable="true">Должность</th>
<th data-field="ismpi" data-sortable="true">МПИ</th>
<th data-field="isbdm" data-sortable="true">БДМ</th>
<th data-field="isowner" data-sortable="true">Заказчик</th>
<th data-field="isarchitector" data-sortable="true">Архитектор</th>
<th data-field="ispm" data-sortable="true">Руководитель портфеля</th>
<th data-field="perm_viewrep" data-sortable="true">Видит все отчеты</th>
<th data-field="perm_editrep" data-sortable="true">Админ шаблонов отчетов</th>
<th data-field="perm_board" data-sortable="true">Видит дашборд</th>
<th data-field="active" data-sortable="true">Активно</th>
</tr>
</thead>
</table>
<script>
$table = $('#table-users')
$table.bootstrapTable({
url: "{{ route('getUsers') }}",locale: 'ru-RU',cookie: 'true',cookieIdTable: 'table-users',search: 'true',advancedSearch: 'true',idTable: 'advancedTable',pagination: 'true',showRefresh: 'true',showFullscreen: 'true',showSearchClearButton : 'true',showColumns: 'true',showColumnsToggleAll: 'true',buttons: buttons(),buttonsOrder: ['advancedTab','userAdd','refresh','fullscreen','columns','exportExcel','clearSearch'],icons: {refresh: 'fa-refresh',fullscreen: 'fa-arrows-alt',columns: 'fa-th-list',advancedSearchIcon: 'fa-search-plus',clearSearch: 'fa-trash'}
});
$('#btn-create-user').click(function (e) {
e.preventDefault();
$.ajax({
url: '{{route('createUser')}}',method: 'POST',data: $('#create-user-form').serialize(),success: function (data) {
console.log(data)
},error: function (jqXHR,exception) {
var msg = '';
if (jqXHR.status === 0) {
msg = 'Not connect.\n Verify Network.';
} else if (jqXHR.status == 404) {
sg = 'Requested page not found. [404]';
} else if (jqXHR.status == 500) {
$msg = 'Internal Server Error [500].';
} else if (exception === 'parsererror') {
msg = 'Requested JSON parse failed.';
} else if (exception === 'timeout') {
msg = 'Time out error.';
} else if (exception === 'abort') {
msg = 'Ajax request aborted.';
} else {
msg = 'Uncaught Error.\n' + jqXHR.responseText;
}
alert($msg);
},});
});
function buttons () {
return {
userAdd: {
text: 'Добавить пользователя',icon: 'fa-user',event: function () {
$('#modalCreateUser').modal('toggle')
},attributes: {
title: 'Добавить пользователя'
}
},clearSearch: {
text: 'Сброс параметров поиска',icon: 'fa-search-minus',event: function () {
$('#advancedSearch').trigger('reset')
$('#create-user-form').trigger('reset')
$table.bootstrapTable('advancedSearch'); //dont work
// example: $table.boostrap('refresh') its work for custom button for refresh data
},attributes: {
title: 'Сброс параметров поиска'
}
},exportExcel: {
text: 'Выгрузить в формате Excel',icon: 'fa-download',event: {
},attributes: {
title: 'Выгрузить в формате Excel'
}
}
}
}
</script>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。