From dee4df2eeed5031968e6da7b7bf9389bd02cecff Mon Sep 17 00:00:00 2001 From: Leander Schulten Date: Thu, 2 Apr 2020 13:11:05 +0200 Subject: [PATCH] Add filterFunction property --- README.md | 1 + src/vue-bootstrap-select.vue | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 8287980..bf85b06 100644 --- a/README.md +++ b/README.md @@ -67,4 +67,5 @@ And arrays of objects | showDefaultOption | sets the select title is set as an option | Boolean | false | | | textProp | the option's prop that is displayed as the option's text | String | text | | | valueProp | the option's prop that is used to find the selected value | String | value | +| filterFunction | a function that can be used to do own filtering | Function (options, searchValue) => filteredOptions | lowercase string comparison | diff --git a/src/vue-bootstrap-select.vue b/src/vue-bootstrap-select.vue index 99e622b..1755e82 100644 --- a/src/vue-bootstrap-select.vue +++ b/src/vue-bootstrap-select.vue @@ -92,6 +92,10 @@ export default { valueProp: { type: String, default: "value" + }, + filterFunction: { + type: Function, + default: null } }, data() { @@ -110,6 +114,9 @@ export default { }, filteredOptions() { if (this.searchable && this.searchValue.length > 0) { + if (this.filterFunction) { + return this.filterFunction(this.options, this.searchValue); + } return this.options.filter(item => { if (typeof item === "object") { return (