Highlight Global filter keyword in filtered data table

UI Components for React
Post Reply
Sakshi.Gupta6
Posts: 9
Joined: 05 Jul 2021, 15:28

29 Apr 2022, 08:54

I want to highlight the searched global filter keyword in data table but didn't get any property to enable that feature, Is that available in prime react data table or not ?

Any way to achieve this in prime react data table without affecting any other action and view of the table?

Something like this: https://datatables.net/blog/2017-01-19

Thanks!

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

02 May 2022, 14:42

You probably want to use a library like this Mark.js: https://markjs.io/
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Sakshi.Gupta6
Posts: 9
Joined: 05 Jul 2021, 15:28

06 Jun 2022, 14:12

Thanks Melloware!

Yes, Mark.js highlight the result but that have application crash issues as well in some cases.

like if I'm applying the filter as well on the bases of same searched keyword, in that case when first time I search eg: "am" then it will highlight in table but after that if I edit the search and do that ""amm" then in that case application crash, because the records which doesn't have double "mm" will be removed from dom and in the same time Mark js apply the unmark function on pre-highlighted records, and some pre-highlighted records will not exist in dom now so application crash with error null.unmark is not a function

I implemented that in some other ways, thanks for your quick response!

Johnnydept
Posts: 2
Joined: 16 Jun 2022, 03:40

16 Jun 2022, 03:49

Thanks Melloware!

Yes, Mark.js highlight the result but that have application crash issues as well in some cases.

like if I'm applying the filter as well on the bases of same searched keyword, in that case when first time I search eg: "am" then it will highlight in table but after that if I edit the search and do that ""amm" then in that case application crash, because the records which doesn't have double "mm" will be removed from dom and in the same time Mark js apply the unmark function on pre-highlighted records, and some pre-highlighted records will not exist in dom now so application crash with error null.unmark is not a function

I implemented that in some other ways, thanks for your quick response!

Melloware
Posts: 3717
Joined: 22 Apr 2013, 15:48

18 Jun 2022, 14:06

I don't know what "crash" means? Do you mean JavaScript error it sounds like you simply have a bug in your code using Mark.js.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests