Bootstrap Table - search test
Bootstrap table - simple demo with inline bootstrap.js, created to show issue with some char sets not being searchable (https://github.com/wenzhixin/bootstrap-table/issues/1906)
HTML
<link rel="stylesheet" href="https://rawgit.com/wenzhixin/bootstrap-table/master/src/bootstrap-table.css">
<table id="table" data-search="true" data-search-align="left">
<thead>
<tr>
<th data-field="fields.name" data-searchable="true">Name</th>
<th data-formatter="myNameFormatter" XXdata-field="fields.name2" XXdata-sort-name="fields.name2">Name 2</th>
<th data-field="stargazers_count">Stars</th>
<th data-field="forks_count">Forks</th>
<th data-field="description">Description</th>
</tr>
</thead>
</table>
JavaScript
// Bootstrap table - simple demo with inline bootstrap.js, created to show issue with some char sets not being searchable (https://github.com/wenzhixin/bootstrap-table/issues/1906)
/**
* @author zhixin wen <[email protected]>
* version: 1.10.0
* https://github.com/wenzhixin/bootstrap-table/
*/
!function ($) {
'use strict';
// TOOLS DEFINITION
// ======================
var cachedWidth = null;
// it only does '%s', and return '' when arguments are undefined
var sprintf = function (str) {
var args = arguments,
flag = true,
i = 1;
str = str.replace(/%s/g, function () {
var arg = args[i++];
if (typeof arg === 'undefined') {
flag = false;
return '';
}
return arg;
});
return flag ? str : '';
};
var getPropertyFromOther = function (list, from, to, value) {
var result = '';
$.each(list, function (i, item) {
if (item[from] === value) {
result = item[to];
return false;
}
return true;
});
return result;
};
var getFieldIndex = function (columns, field) {
var index = -1;
$.each(columns, function (i, column) {
if (column.field === field) {
index = i;
return false;
}
return true;
});
return index;
};
// http://jsfiddle.net/wenyi/47nz7ez9/3/
var setFieldIndex = function (columns) {
var i, j, k,
totalCol = 0,
flag = [];
for (i = 0; i < columns[0].length; i++) {
totalCol += columns[0][i].colspan || 1;
}
for (i = 0; i < columns.length; i++) {
flag[i] = [];
for (j = 0; j < totalCol; j++) {
flag[i][j] = false;
}
}
for (i = 0; i < columns.length;...