Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataTable: improve globalFilterFields type #5212

Closed
ghost opened this issue Feb 5, 2024 · 1 comment
Closed

DataTable: improve globalFilterFields type #5212

ghost opened this issue Feb 5, 2024 · 1 comment
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@ghost
Copy link

ghost commented Feb 5, 2024

Describe the bug

Hello everyone,

We needed to implement custom search logic for a table row property that was an array. The specs say that globalFilterFields is a type of string[] but it seems that it also takes a function instead of string. So custom filtering actually works. The below example works just fine, eq.

<DataTable
      ...
      :globalFilterFields="[
        'name',
        'country.name',
        'representative.name',
        'status',
        (d) =>
          Array.isArray(d.country)
            ? d.country.map((c) => c.name).join(' ')
            : d.country.name,
      ]"
/>

Reproducer

https://stackblitz.com/edit/husnuh-yncidy?file=src%2FApp.vue,src%2Fservice%2FCustomerService.js

PrimeVue version

^3.46.0

Vue version

3.x

Language

TypeScript

Build / Runtime

Vue CLI App

Browser(s)

Chrome

Steps to reproduce the behavior

Check this example

  1. Here I modified one record (id: 1001) so the country is an array with two countries.
  2. The globalFilterFields takes also a method as one of the list items
  3. Table search works correctly and also filters by countries that are arrays
  4. Countries declared as arrays are not displayed properly because I didn't handle it but that's a correct behavior

Expected behavior

globalFilterFields type should be improved by adding a function to it.

Something like:

globalFilterFields: (string | ((rowData: unknown) => string))[]
@ghost ghost added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Feb 5, 2024
@mertsincan
Copy link
Member

Thanks a lot for your report! I set a milestone for it. We'll check it before the milestone is released. Also, you can send a PR for it if you want ;)

@mertsincan mertsincan added Status: Pending Review Issue or pull request is being reviewed by Core Team and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Feb 9, 2024
@mertsincan mertsincan added this to the 3.51.0 milestone Feb 9, 2024
@tugcekucukoglu tugcekucukoglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Pending Review Issue or pull request is being reviewed by Core Team labels Mar 19, 2024
@tugcekucukoglu tugcekucukoglu self-assigned this Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

2 participants