Vue 3 - Filtering on dynamic Datatable

UI Components for Vue
Post Reply
Eireternal
Posts: 6
Joined: 06 Nov 2020, 21:29

03 Dec 2020, 14:05

Is this possible? I can't get filters to work with the following code. The filter input boxes appear, I type but nothing changes.
The documentation shows an example with hardcoded Columns. Could this be an issue with dynamically looped Columns?

Also please look at the v-model value. I know its supposed to have a string in the filters array. The col.field type is string but is my syntax here correct? Thanks for any help.

Code: Select all

<DataTable :value="entries"
               :paginator="true"
               class="p-datatable-customers p-datatable-sm p-datatable-responsive d-table"
               :rows="100"
               dataKey="id"
               :filters="filters"
               removableSort
               autoLayout="true"
               resizableColumns="true">
<Column v-for="col of columns" :field="col.field" :header="col.header" :key="col.field" sortable="true" filterMatchMode="contains">
            <template #filter>
                <InputText type="text" v-model="filters[col.field]" class="p-column-filter" />
            </template>
            <template #body="slotProps">
                <span class="p-column-title" v-tooltip.top="slotProps.data[col.field]"><span>{{col.header}}:</span> {{slotProps.data[col.field]}}</span>

            </template>
        </Column>
</Datatable>

Herald
Posts: 6
Joined: 07 Apr 2021, 08:03

09 Apr 2021, 18:56

Hi Eireternal,
are you still facing the issue? any error?
even i am using dynamic columns and that worked for me, credits to you (i implemented after seeing your code, tq for that)

sanjosebadger
Posts: 1
Joined: 04 Jun 2023, 03:34

09 Jun 2023, 08:45

i'm having the same propblem. Have you solved the issue?

Post Reply

Return to “PrimeVue”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests