I have a table made with bootstrap-table and I have a column "status" in which a cell can contains multiple html badges.
I have a select data-filter-control but it doesn't work correctly. The first problem was that I had html content in filter selection like this:
I resolved the first problem by add a data-filter-data-collector like this :
<th data-field="status" data-filter-control="select" data-align="center" data-filter-data-collector="tableFilterStripHtml">Status</th>
Here the js code for tableFilterStripHtml:
window.tableFilterStripHtml = function (value) {
return value.replace(/<[^>]+>/g, '').trim();
}
Now the filter still doesn't work correctly. The problem is that I have same data in multiple rows selection of the filter. And for one row I should have one data, not multiple. See this:
How to fix this problem?
Just found the solution by myself, here the js code :
window.tableFilterStripHtml = function (value) {
var badges = value.match(/<span[^>]*>(.*?)<\/span>/g) || [];
return badges.map(function (badge) {
return badge.replace(/<[^>]+>/g, '').trim();
});
};