question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using onBlur to activate the filter instead of using onFilterChange

See original GitHub issue

I am using server-side filtering, I overrode onFilterChange to activate filter every time the filter list is changed, but the problem is every time the filter list is changed, the backend API will be called to update the table’s data. It makes the layout quite lag and the backend is called too much. I want to filter every time the user leaves the field or maybe we will add the button in TableList called Submit Filter, as soon as the user enters all the field they need to filter then click the button to activate the filter.

Tech Version
Material-UI 3.9.2
MUI-datatables 2.8.0
React 16.8.5
browser Chrome
etc

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:23

github_iconTop GitHub Comments

5reactions
mbniebergallcommented, Nov 4, 2019

@nmdhulipud this was released in 2.12.0 (see https://github.com/gregnb/mui-datatables/releases/tag/2.12.0). I have already implemented using it on a project and performance is significantly improved. Thanks @gabrielliwerant !

1reaction
nbrusteincommented, Sep 3, 2019

Mostly just to summarize what people have already said clearly.

Problem: When using the serverSide option, onFilterChange and onTableChange are often called too much. In responding to them, you end up hammering your API with new requests that aren’t really for what the user wants, since the user is not yet finished filling out their desired filters or typing in the search box.

Solutions

  1. Apply button on the filter form and on the search input. These buttons could be attached to a new event (or new events, one for each). A developer could then respond to those events and only trigger an API call when the user indicates they are finished entering their filters. If this solution is implemented, it might also be necessary to make configurable the text on the button on the actual component used for the button, and to do these separately for the search box and the filter form.
  2. onBlur events for the filter form and the search input.
  3. debounce logic. It is currently possible for the developer to implement this herself, but it would also be possible to either add new events that only get triggered after a debounced delay, or to add configuration that allows for debouncing the existing events. (It might also be possible, rather than making this configuration, to provide a hook that debounces the table state changes.)

Would you be willing to consider PRs for any/all of these things if someone were to submit them?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to subscribe for a filter changed event in ag grid
Ag grid has callbacks 'onFilterChanged' & 'onFilterModified' var gridOptions = { columnDefs: columnDefs, rowData: null, enableFilter: true, ...
Read more >
Grid Events - JavaScript Data Grid
This is a list of the events that the grid raises. You register callbacks for these events through the GridOptions interface. The name...
Read more >
Multiselect onBlur event not firing in KendoReact - Telerik
Hi,My code is set up as below - tabbing or using the mouse to navigate to ... not trigger the onBlur event everything...
Read more >
filter - CSS: Cascading Style Sheets - MDN Web Docs - Mozilla
The filter CSS property applies graphical effects like blur or color shift to an element. Filters are commonly used to adjust the rendering ......
Read more >
Matrix Filter (A, ABBR, ACRONYM, ...)
Use the Matrix filter to create the following simple effects. Flip horizontal. ... Blur(pixelradius=2) progid:DXImageTransform.Microsoft.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found