Is there any possibility to apply filter at the first init?

Tags: #<Tag:0x00007fd2cd01c258>

Hi, I’m trying to show a table with users (first name, last name, sex, date of birth).
What I want is to apply a filter to only show male users at the initialisation of the table.

I found how to apply filter after the first render here. But in the example, the table is rendered, and then we hide some data. But I’ll have a lot of users. So what I need is to don’t render all of the female users to hide them 1 sec after.

Is it possible to apply filters at the first initialisation without render then hide them ?

Antoine Duval.

Hey @duval.antoine

here’s an example for you
I’ve used the addCondition method and filter to trigger filtering and table rerender.

Thanks for your help @aleksandra_budnik.

I appreciate your speed.

Unless I make a mistake, in your example, the table will be rendered twice :

  • 1 : The table is rendered with all data.
  • 2 : The table is rendered with less data (due to filter).

Am I right ?

That is actually a great question! I thought that maybe calling the logic inside the afterLoadData will do the work but it prints errors.
The best approach is to call it in the afterInit hook (we get 2 calls)