Filtering Best Practices
Follow these guidelines for a better filtering experience. This section lists recommended practices.
Debounce Filter Inputs
Many filters require user input. If you apply a filter immediately as the user enters values, ensure that you debounce the input. Applying filters on every keystroke is not recommended, since each change often requires re-evaluating all filter operations for every row.
For more information on debouncing as a pattern, see the MDN Debounce guide.
Handle Null Values
Always account for null values. In your filter logic, make a deliberate decision about
whether null values should be kept or removed. The presence of null values is often
an afterthought, but handling them incorrectly can make filter implementations more complex
and less predictable.
Ensure Filter Efficiency
Filters run against every row, so keep filter functions efficient and avoid heavy computation inside filter logic.
Some LyteNyte Grid row sources accept an array of filter functions, such as the client row source. The grid evaluates filter functions in the order provided. Order filters from most efficient to least efficient to maximize performance.
Display Filter Feedback
Always provide a visible indication that filters are active. This feedback can be as simple as a filter icon or a subtle but noticeable color indicator. Use consistent visual cues for filter feedback, and always provide a clear way to remove or reset filters.
Next Steps
- Filtering Numbers: Filter row data based on numerical cell values.
- Filtering Text: Create and apply text filters to client-side data.
- Filtering Dates: Learn how to create custom date filters.
