diff --git a/package.json b/package.json index 8b757d4..1782fa0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "handsontable-key-value", - "version": "3.0.2", + "version": "3.0.3", "description": "Handstontable plugin to handle key-value pair data type.", "repository": { "type": "git", @@ -35,7 +35,7 @@ "rimraf": "^2.6.3" }, "peerDependencies": { - "handsontable": "^7.0.0" + "handsontable": ">=7.0.0" }, "dependencies": { "lodash.deburr": "^4.1.0" diff --git a/src/filters/keyValueMultipleSelectUI.js b/src/filters/keyValueMultipleSelectUI.js index a029507..7ebefb9 100644 --- a/src/filters/keyValueMultipleSelectUI.js +++ b/src/filters/keyValueMultipleSelectUI.js @@ -9,8 +9,26 @@ class KeyValueMultipleSelect extends MultipleSelectUI { return; } - // Don't know why in the official version we compute again the checked values, - // as it's already done by ValueComponent. So, just load the items. + // If the filter has been set programmatically, we need to retrive which item(s) should be checked + const lastSelectedColumn = this.hot.getPlugin('filtersKeyValue').getSelectedColumn(); + if (this.items.length) { + const { conditions } = this.hot.getPlugin('filtersKeyValue').conditionCollection; + if (conditions.conjunction) { + const toCheck = conditions.conjunction[lastSelectedColumn.visualIndex]; + if (toCheck) { + toCheck.forEach((filter) => { + if (filter.name === 'by_value') { + this.items.forEach((item) => { + item.checked = filter.args.flat().includes(item.value); + }); + } + /** @todo Handle other cases than 'by_value' ? */ + }); + } + } + /** @todo Is it needed for disjuntion case ? */ + } + // else it's already done by ValueComponent. So, just load the items. this.itemsBox.loadData(this.items); }