Replies: 3 comments
-
|
For TreeTable, Table and column filters this already works, FilterService.register is public: const subMap: Record<string, string> = {
'₀':'0','₁':'1','₂':'2','₃':'3','₄':'4','₅':'5','₆':'6','₇':'7','₈':'8','₉':'9',
'⁰':'0','¹':'1','²':'2','³':'3','⁴':'4','⁵':'5','⁶':'6','⁷':'7','⁸':'8','⁹':'9',
};
const normalise = (s: string) => s.replace(/[₀-₉⁰-⁹]/g, c => subMap[c] ?? c);
constructor(private filterService: FilterService) {
this.filterService.register('normalisedContains', (value, filter, locale) => {
if (filter == null || String(filter).trim() === '') return true;
if (value == null) return false;
return normalise(String(value)).toLocaleLowerCase(locale)
.includes(normalise(String(filter)).toLocaleLowerCase(locale));
});
}Then on the table: Select and MultiSelect are the problem. Their AutoComplete doesn't use FilterService at all, For H2O specifically, applying |
Beta Was this translation helpful? Give feedback.
-
|
Thank you very much for your elaborate answer Éverton (ᵔ⩊ᵔ). I could not replicate your issue with the single/multi-selects, my filter works with them, even when I use your code, no as any required. Or at which exact position do you need to cast? I also noticed that this way of global table filtration does not work at all when you combine it with lazy loading, added an issue for that primefaces/primeng#19539 Thank you very much for getting the discussion started (^▽^). |
Beta Was this translation helpful? Give feedback.
-
|
Glad it helped. On the Select/MultiSelect typing: the cast is only needed at template-binding time (not at runtime), and only when Angular's strict template checking is on. In the current sources (v21.1.6, published 2026-04-13; same blobs on
Both identical: @Input() filterMatchMode:
'contains' | 'startsWith' | 'endsWith' | 'equals' | 'notEquals'
| 'in' | 'lt' | 'lte' | 'gt' | 'gte' = 'contains';Internally they both call If the error isn't showing up on your side, could you check whether
Two cleaner ways to avoid
Widening the Input to On the lazy-loading bit (#19539), that one is structural, not a config issue. // table.ts:2215
if (this.lazy) {
this.onLazyLoad.emit(this.createLazyLoadMetadata());
} else {
// local filtering, the only branch that hits
// filterService.filters[matchMode] (executeLocalFilter, line 2323)
}So with
Three options, depending on where your data lives:
I'd keep the issue open. At minimum a docs note ("registered custom match modes aren't executed in lazy mode; implement the equivalent server-side or pre-normalise on the client"), and ideally the match-mode name being surfaced explicitly in the lazy event payload so the server-integration path is less ad-hoc. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Issue
Hi there, I am trying to implement custom filtration for all entities we have, which are iterated over in different PrimeNG components.
What I exactly would like to do is just being able to search for entities that haver sub or super texts in them by just entering their normal characters. Like one entity is called "H₂O", and it should be searchable via "H2O" as well.
But I think the need for different custom string replacements or other ways of filtration will come up in the future and being able to easily overwrite the filtration in PrimeNG components would be desirable in general.
I see three possible ways in achieving that:
Suggested solution
Integrating the FilterService with its way of registering a new filter, and the column filter way of the choosing the filtration method in the template.
It is so easy to do without messing up the code base, but is as of now limited to the treetable and column filters.
I don't know if there is internal intrest in integration at Primefaces, but I would at least like put my request out there for discussion.
And maybe someone has a better way of doing what i want and could provide with a different solution as well, thank you very much for your interest.
I also saw a similar post p-tree table integration with filter service, but it is less precise about what the issue is, more specific in scope and might have a different solution from this one, so I created a new one but of course would be happy if both get merged.
Beta Was this translation helpful? Give feedback.
All reactions