Я использую плагин Bootstrap-table (http://bootstraptable.wenzhixin.net.cn/documentation/), и я пытаюсь фильтровать по тэгам, используя метод filterby
, но не могу понять, как фактор в нескольких тегах, которые должны входят в виде строки, разделенной запятыми.Bootstrap Table filter by string partial
Я создал пример, иллюстрирующий то, что я пытаюсь достичь. Для простоты
Вот HTML:
<table id="table">
<thead>
<tr>
<th data-field="date">Date</th>
<th data-field="desc">Description</th>
<th data-field="tags">Tags</th>
</tr>
</thead>
</table>
<br>
<button id="filter-general">General</button>
<button id="filter-rotation">Rotation</button>
<button id="clear">clear</button>
Javascript:
var data = [{
"date": "2016-05-10",
"tags": "General, Research, Rotation",
"desc": "Nunc velit lectus, ornare vitae fringilla eget, vestibulum quis tortor."
},{
"date": "2016-04-22",
"tags": "General",
"desc": "Nunc velit lectus, ornare vitae fringilla eget, vestibulum quis tortor."
},{
"date": "2016-03-23",
"tags": "Research, Rotation",
"desc": "Nunc velit lectus, ornare vitae fringilla eget, vestibulum quis tortor."
},{
"date": "2015-11-01",
"tags": "Rotation",
"desc": "Nunc velit lectus, ornare vitae fringilla eget, vestibulum quis tortor."
},{
"date": "2016-08-15",
"tags": "General, Rotation",
"desc": "Nunc velit lectus, ornare vitae fringilla eget, vestibulum quis tortor."
}];
$(function() {
$table = $('#table');
$table.bootstrapTable({
data: data
});
$('#clear').click(function() {
$table.bootstrapTable('filterBy', {});
});
$('#filter-general').click(function() {
$table.bootstrapTable('filterBy', {
tags: "General"
});
});
$('#filter-rotation').click(function() {
$table.bootstrapTable('filterBy', {
tags: "Rotation"
});
});
});
http://jsfiddle.net/zqxwr3uL/6/
Edit: Либо filterby
метод или один из расширений фильтра с.
Считаете ли вы, что одно из двух расширений может достичь такого поведения? Все еще изучая его, но не может понять, как это может выглядеть с помощью частичной строки. –