Closed anis-campos closed 6 years ago
hi @theking973,
I've implemented new method which allows to set up filter programatically. See the plunker here http://plnkr.co/edit/JkRMZt?p=preview
$('#filter-bar').bootstrapTableFilter('setupFilter', 'price', {lte: 3});
$('#filter-bar').bootstrapTableFilter('setupFilter', 'name', {_values: ['0', '1']});
Regarding your second question, it is possible to define filter type when you initialize filter using the "filters" options. When the filter is initiated, you can remove filter and then add it again with different type:
$('...').bootstrapTableFilter('removeFilter', 'field_id');
$('...').bootstrapTableFilter('addFilter',{
field: 'role',
label: 'Role',
type: 'select',
values: [
{id: 'ROLE_ANONYMOUS', label: 'Anonymous'},
{id: 'ROLE_USER', label: 'User'},
{id: 'ROLE_ADMIN', label: 'Admin'}
],
});
I haven't tested the code but I think it should work Lukas
Hi @lukaskral, I want to put select filter
$(function(){
var table = $('#table-siaho');
table.bootstrapTable({
exportTypes: ['doc'],
pageSize: 25,
visible: true,
showToggle: true,
showExport: true,
filterControl: true,
pagination: true,
pageList: [10, 25, 50, 100],
striped: true,
search: true,
smartDisplay: true,
showColumns: true,
showRefresh: true,
sortName: 'idremision',
sortOrder: 'desc',
url: baseUrl+'siaho/get_pacientes',
showFooter: true,
columns: [{
sortable: true,
field: 'expediente',
title: 'Expediente'
}, {
sortable: true,
field: 'paciente',
title: 'Nombre del paciente',
}, {
sortable: true,
field: 'cama',
title: 'Cama'
}, {
sortable: true,
field: 'servicio',
title: 'Servicio',
filterControl: 'input'
}, {
sortable: true,
field: 'especialidad',
title: 'Especialidad',
filterControl: 'input'
}, {
sortable: true,
field: 'area',
title: 'Área',
filterControl: 'select'
}]
});
$('#filter-bar').bootstrapTableFilter({
filters:[
{
field: 'area',
label: 'Area',
type: 'select',
values: [
{id: 'URGENCIAS ADULTOS', label:'URGENCIAS ADULTOS'},
{id: 'TOCOLABOR', label: 'TOCOLABOR'},
{id: 'ADMISION', label: 'ADMISION'}
],
}
],
connectTo: '#table-siaho',
onSubmit: function() {
var data = $('#filter-bar').bootstrapTableFilter('getData');
console.log(data);
}
});
});
the only thing showing up is a RANGE filter for each (less than, more than, equals). Help, please
Hello,
I want to initialize the filter bar with an active filter which is also initialised with a value.
For example, when the table is created, I would like the column "state" filtered with the condition equal to "added".
Edit
I have a second question : How to edit a filter.
I want to change the type a filter, for example, from "search" to "check"