DataTable filter matchMode type issues

UI Components for Vue
Post Reply
colinbes
Posts: 17
Joined: 26 May 2021, 23:50

18 Feb 2022, 01:25

vue: 3.2.16
primevue: 3.12.0
vue-tsc: 0.29.8 (and have tried 0.30.0)
vite: 2.6.4

Today I decided to update due vite, vue and primevue and it broke - I rolled back but to prior version and even deleted package-lock and node_modules folder and did npm install but issue remains.

Using npm run dev gives no errors and vue app works with no issues, however when trying to build and running vue-tsc I get errors on DataTable filters - example error shown below:

Code: Select all

Type '{ action: { value: null; matchMode: string; }; }' is not assignable to type 'DataTableFilterMeta'.
In my component template I have:

Code: Select all

      <DataTable
        :value="actions"
        class="p-datatable-sm"
        dataKey="_id.$oid"
        :rowHover="true"
        v-model:filters="myFilters"
        ....
And in vue3 composition api script I have:

Code: Select all

<script lang="ts">
import { FilterMatchMode, FilterOperator } from "primevue/api"
..
setup: (props, context) => {
    const myFilters = ref({
      'action': {value: null, matchMode: FilterMatchMode.EQUALS}
    })
    ...
}
...
</script>
Confusing part is that matchMode should be type DataTableFilterMatchModeType which is a string.

I will dig in more tomorrow but was hoping someone may have seen this and have some ideas

colinbes
Posts: 17
Joined: 26 May 2021, 23:50

18 Feb 2022, 02:02

To me it looks like import { FilterMatchMode } from 'primevue/api' is pulling in a type definition and not the values to be used to set the mode.

In file api.js there is FilterMatchMode with actual values which is what we want, but I don't see how to import this FilterMatchMode found in node_modules/primevue/api/api.js which doesn't feel right either.

Code: Select all

const FilterMatchMode = {
        STARTS_WITH : 'startsWith',
        CONTAINS : 'contains',
        NOT_CONTAINS : 'notContains',
        ENDS_WITH : 'endsWith',
        ...

colinbes
Posts: 17
Joined: 26 May 2021, 23:50

18 Feb 2022, 21:59

Rolling back different versions of PrimeVue it appears that this issue came about with 3.9.1 to 3.10.0 update.

tugce.kucukoglu
Posts: 560
Joined: 23 Oct 2020, 09:28

03 Mar 2022, 08:55

Please try to use 3.12.1

Post Reply

Return to “PrimeVue”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests