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 Custom Global Filter #7639

Closed
TylerFPM opened this issue Jan 22, 2025 · 2 comments
Closed

DataTable Custom Global Filter #7639

TylerFPM opened this issue Jan 22, 2025 · 2 comments
Assignees
Labels
Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team

Comments

@TylerFPM
Copy link

TylerFPM commented Jan 22, 2025

Is it possible to register a custom filter for the global filter? I have attempted to do this but can't get it to work by setting global: { value: null, matchMode: FilterMatchMode.CUSTOM } and registering the custom function FilterService.register('custom_global'...

For context I would like the global search field to be able to search values of one column which is an array of objects. I've been able to implement a custom filter on the column in question to achieve some filtering but would the global search to also be able to do this.

@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jan 22, 2025
@melloware
Copy link
Member

I don't think this is supported.

@melloware melloware added question Issue contains a question about the use of PrimeReact components or the products it supports and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jan 23, 2025
@sja-cslab
Copy link
Contributor

sja-cslab commented Jan 23, 2025

We override the global that way:

const [filters, setFilters] = useState({
        global: {
            value: null,
            matchMode: "custom_global"
        }
    });

and pass that filters to datatable filters property.
Using the whole thing with custom header={renderHeader} with an input, replacing the old one
<InputText value={globalFilterValue} onChange={onGlobalFilterChange} placeholder={"mycustom global filter"} />

@melloware melloware added Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team and removed question Issue contains a question about the use of PrimeReact components or the products it supports labels Jan 23, 2025
@melloware melloware closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team
Projects
None yet
Development

No branches or pull requests

3 participants