# Filter by business conditions

Connect business conditions outside the Grid through a row predicate. Use this when external UI choices, such as incomplete items or items assigned to you, control the table.

Canonical: https://grid.syidax.com/docs/features/external-filter/

<a id="understand"></a>

## How it works and when to use it

The Grid cannot automatically detect changes to external condition variables. Call refreshExternalFilter to recalculate.

In the code, grid is the Grid element prepared in the installation chapter. Check each example's data and settings, and implement the app functions and server endpoints for your project.

- [Installation and integration · Shared sample data](https://grid.syidax.com/docs/guides/getting-started.md)

<a id="example-1"></a>

## Example 1. Show only large-quantity orders

Connect a business switch that shows quantities of at least 100.

```javascript
let largeOnly = true;
grid.externalFilter = {
  isExternalFilterPresent: () => largeOnly,
  doesExternalFilterPass: row => Number(row.quantity) >= 100
};
await grid.refreshExternalFilter();
```

Verify the result: Apply the predicate only when the switch is on. The function must return a boolean without mutating the source row.

<a id="example-2"></a>

## Example 2. Clear an external condition

Keep the same filter object and change only the external variable.

```javascript
largeOnly = false;
await grid.refreshExternalFilter();
```

Verify the result: The external filter is cleared, but column filters and quick search may remain active.

<a id="example-3"></a>

## Example 3. Change the app context

When the signed-in user changes, update the user information read by the external filter and recalculate. Lifecycle instances can clean up resources through refresh and destroy.

Verify the result: Conditions from the previous user do not remain. The server must also withhold source values the new user is not authorized to view.

<a id="pitfalls"></a>

## Combining features and troubleshooting

Do not return an asynchronous network response as if it were a boolean predicate. Prepare the required information first, then recalculate the filter.

Conditions requiring a search of the full server data set must also be sent to the server. An external filter cannot derive complete results from loaded client rows alone.

<a id="related-api"></a>

## APIs used by this feature

- [externalFilter](https://grid.syidax.com/docs/options/externalFilter.md) — Determines whether each row passes conditions outside the Grid. Supply activation and row predicates or a lifecycle instance.
- [refreshExternalFilter](https://grid.syidax.com/docs/methods/refreshExternalFilter.md) — Runs the external filter refresh lifecycle and returns success.

<a id="next"></a>

## Related reading

- [How rows, columns, and IDs relate](https://grid.syidax.com/docs/guides/concepts.md)
- [Connect results and events](https://grid.syidax.com/docs/guides/data-event-access.md)
- [Explore in Features](https://grid.syidax.com/grid/external-filter) — The guide describes which interactions are available to try.
