Fixed #655 - DataTable global filter bug
parent
65e0c19047
commit
0bf807591e
|
@ -607,13 +607,13 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!col.props?.excludeGlobalFilter && this.hasGlobalFilter && !globalMatch) {
|
if (!col.props?.excludeGlobalFilter && this.hasGlobalFilter() && !globalMatch) {
|
||||||
globalMatch = FilterUtils.contains(ObjectUtils.resolveFieldData(data[i], columnField), this.filters['global'], this.filterLocale);
|
globalMatch = FilterUtils.contains(ObjectUtils.resolveFieldData(data[i], columnField), this.filters['global'], this.filterLocale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let matches = localMatch;
|
let matches = localMatch;
|
||||||
if (this.hasGlobalFilter) {
|
if (this.hasGlobalFilter()) {
|
||||||
matches = localMatch && globalMatch;
|
matches = localMatch && globalMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1459,7 +1459,7 @@ export default {
|
||||||
state.multiSortMeta = this.d_multiSortMeta;
|
state.multiSortMeta = this.d_multiSortMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasFilters) {
|
if (this.hasFilters()) {
|
||||||
state.filters = this.filters;
|
state.filters = this.filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1619,7 +1619,7 @@ export default {
|
||||||
},
|
},
|
||||||
createLazyLoadEvent(event) {
|
createLazyLoadEvent(event) {
|
||||||
let filterMatchModes;
|
let filterMatchModes;
|
||||||
if (this.hasFilters) {
|
if (this.hasFilters()) {
|
||||||
filterMatchModes = {};
|
filterMatchModes = {};
|
||||||
this.columns.forEach(col => {
|
this.columns.forEach(col => {
|
||||||
if (col.field) {
|
if (col.field) {
|
||||||
|
@ -1639,6 +1639,12 @@ export default {
|
||||||
filterMatchModes: filterMatchModes
|
filterMatchModes: filterMatchModes
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
hasFilters() {
|
||||||
|
return this.filters && Object.keys(this.filters).length > 0 && this.filters.constructor === Object;
|
||||||
|
},
|
||||||
|
hasGlobalFilter() {
|
||||||
|
return this.filters && Object.prototype.hasOwnProperty.call(this.filters, 'global');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
containerClass() {
|
containerClass() {
|
||||||
|
@ -1761,7 +1767,7 @@ export default {
|
||||||
data = this.sortMultiple(data);
|
data = this.sortMultiple(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasFilters) {
|
if (this.hasFilters()) {
|
||||||
data = this.filter(data);
|
data = this.filter(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1805,12 +1811,6 @@ export default {
|
||||||
sorted() {
|
sorted() {
|
||||||
return this.d_sortField || (this.d_multiSortMeta && this.d_multiSortMeta.length > 0);
|
return this.d_sortField || (this.d_multiSortMeta && this.d_multiSortMeta.length > 0);
|
||||||
},
|
},
|
||||||
hasFilters() {
|
|
||||||
return this.filters && Object.keys(this.filters).length > 0 && this.filters.constructor === Object;
|
|
||||||
},
|
|
||||||
hasGlobalFilter() {
|
|
||||||
return this.filters && Object.prototype.hasOwnProperty.call(this.filters, 'global');
|
|
||||||
},
|
|
||||||
loadingIconClass() {
|
loadingIconClass() {
|
||||||
return ['p-datatable-loading-icon pi-spin', this.loadingIcon];
|
return ['p-datatable-loading-icon pi-spin', this.loadingIcon];
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue