|
@@ -172,29 +172,29 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|
|
|
|
|
|
|
initSearch () {
|
|
initSearch () {
|
|
|
const that = this
|
|
const that = this
|
|
|
- const fp = $.isEmptyObject(that.filterColumnsPartial) ? null : that.filterColumnsPartial
|
|
|
|
|
|
|
+ const filterPartial = $.isEmptyObject(that.filterColumnsPartial) ? null : that.filterColumnsPartial
|
|
|
|
|
|
|
|
super.initSearch()
|
|
super.initSearch()
|
|
|
|
|
|
|
|
- if (this.options.sidePagination === 'server' || fp === null) {
|
|
|
|
|
|
|
+ if (this.options.sidePagination === 'server' || filterPartial === null) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Check partial column filter
|
|
// Check partial column filter
|
|
|
- that.data = fp ?
|
|
|
|
|
|
|
+ that.data = filterPartial ?
|
|
|
that.data.filter((item, i) => {
|
|
that.data.filter((item, i) => {
|
|
|
const itemIsExpected = []
|
|
const itemIsExpected = []
|
|
|
const keys1 = Object.keys(item)
|
|
const keys1 = Object.keys(item)
|
|
|
- const keys2 = Object.keys(fp)
|
|
|
|
|
|
|
+ const keys2 = Object.keys(filterPartial)
|
|
|
const keys = keys1.concat(keys2.filter(item => !keys1.includes(item)))
|
|
const keys = keys1.concat(keys2.filter(item => !keys1.includes(item)))
|
|
|
|
|
|
|
|
keys.forEach(key => {
|
|
keys.forEach(key => {
|
|
|
const thisColumn = that.columns[that.fieldsColumnsIndex[key]]
|
|
const thisColumn = that.columns[that.fieldsColumnsIndex[key]]
|
|
|
- const fval = (fp[key] || '').toLowerCase()
|
|
|
|
|
|
|
+ const filterValue = (filterPartial[key] || '').toLowerCase()
|
|
|
let value = Utils.unescapeHTML(Utils.getItemField(item, key, false))
|
|
let value = Utils.unescapeHTML(Utils.getItemField(item, key, false))
|
|
|
let tmpItemIsExpected
|
|
let tmpItemIsExpected
|
|
|
|
|
|
|
|
- if (fval === '') {
|
|
|
|
|
|
|
+ if (filterValue === '') {
|
|
|
tmpItemIsExpected = true
|
|
tmpItemIsExpected = true
|
|
|
} else {
|
|
} else {
|
|
|
// Fix #142: search use formatted data
|
|
// Fix #142: search use formatted data
|
|
@@ -219,14 +219,13 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|
|
if (this.options.searchAccentNeutralise) {
|
|
if (this.options.searchAccentNeutralise) {
|
|
|
objectValue = Utils.normalizeAccent(objectValue)
|
|
objectValue = Utils.normalizeAccent(objectValue)
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- tmpItemIsExpected = that.isValueExpected(fval, objectValue, thisColumn, key)
|
|
|
|
|
|
|
+ tmpItemIsExpected = that.isValueExpected(filterValue, objectValue, thisColumn, key)
|
|
|
})
|
|
})
|
|
|
} else if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
} else if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
|
if (this.options.searchAccentNeutralise) {
|
|
if (this.options.searchAccentNeutralise) {
|
|
|
value = Utils.normalizeAccent(value)
|
|
value = Utils.normalizeAccent(value)
|
|
|
}
|
|
}
|
|
|
- tmpItemIsExpected = that.isValueExpected(fval, value, thisColumn, key)
|
|
|
|
|
|
|
+ tmpItemIsExpected = that.isValueExpected(filterValue, value, thisColumn, key)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -248,6 +247,8 @@ $.BootstrapTable = class extends $.BootstrapTable {
|
|
|
tmpItemIsExpected = value.toString().toLowerCase() === searchValue.toString().toLowerCase()
|
|
tmpItemIsExpected = value.toString().toLowerCase() === searchValue.toString().toLowerCase()
|
|
|
} else if (column.filterStartsWithSearch) {
|
|
} else if (column.filterStartsWithSearch) {
|
|
|
tmpItemIsExpected = (`${value}`).toLowerCase().indexOf(searchValue) === 0
|
|
tmpItemIsExpected = (`${value}`).toLowerCase().indexOf(searchValue) === 0
|
|
|
|
|
+ } else if (this.options.regexSearch) {
|
|
|
|
|
+ tmpItemIsExpected = Utils.regexCompare(value, searchValue)
|
|
|
} else {
|
|
} else {
|
|
|
tmpItemIsExpected = (`${value}`).toLowerCase().includes(searchValue)
|
|
tmpItemIsExpected = (`${value}`).toLowerCase().includes(searchValue)
|
|
|
}
|
|
}
|