log-viewer/frontend/src/components/ComboboxFilter.js

37 lines
1002 B
JavaScript

export default {
template: `
<span>
<select v-model="currentValue" style="width: 100px"
>
<option v-for="option in options">
{{ option }}
</option>
<option value=""/>
</select>
</span>
`,
data: function () {
return {
options: [],
currentValue: null,
};
},
watch: {
currentValue (newValue) {
this.params.parentFilterInstance((instance) => {
instance.onFloatingFilterChanged('', newValue);
});
}
},
methods: {
onParentModelChanged(parentModel) {
this.options = this.params.column.colDef.floatingFilterComponentParams.options
// When the filter is empty we will receive a null value here
if (!parentModel) {
this.currentValue = '';
} else {
this.currentValue = parentModel.filter;
}
}
},
};