LyteNyte Grid logo for light mode. Links back to the documentation home page.
Client Row Source

Client Row Filtering

LyteNyte Grid's client row source lets you to set custom filters to exclude specific rows from view. These filtered rows are omitted before actions such as grouping, sorting, or aggregating are executed.

Info

This guide offers an overview of filters, focusing on the client row source properties. For detailed guidance on Filtering, refer to our Filtering Section, beginning with the Filter Text guide.

Filter Property

The filter property on the client row source accepts a filter predicate or an array of filter predicates. A filter predicate is a function that receives a leaf row and returns true if the grid should keep the row or false if the grid should filter the row out.

A basic filter function is shown below. Click the Mastercard button to view only Mastercard payments, or the Visa button to view only Visa payments.

Client Row Filter Function

Fork code on stack blitzFork code on code sandbox

The demo creates a filter function that is passed to the client source, as shown below. This minimal approach supports any filter model, since filtering is an arbitrary predicate function.

const [filter, setFilter] = useState<Grid.T.FilterFn<GridSpec["data"]> | null>(null);
const ds = useClientDataSource<GridSpec>({ data: data, filter });
// Later in the code
<button
onClick={() => {
setFilter(
() => (row: Grid.T.RowLeaf<GridSpec["data"]>) => row.data.paymentMethod === "Mastercard",
);
}}
>

Filter Array

Providing a single filter function is cumbersome when filters originate from different sources. For example, if you support per-column text search, you can write one filter function per column and pass those column filter functions to useClientDataSource.

Filter Function Array

Fork code on stack blitzFork code on code sandbox

Filter Leaf Rows

Filter callbacks passed via the filter property receive leaf rows only because filtering runs before grouping or aggregation. Apply filters to raw rows, not grouped or aggregated output.

For post-grouping filtering in the client source, see the Client Row Having Filter guide.

Next Steps