Advanced Filtering

Set AllowFiltering="true" (allowFiltering in React) and the grid's toolbar gets a Filter button, which opens the view's own filters in the FetchXML query builder for the user to change. Anything FetchXML can filter by can be built: conditions on the table's columns, grouped with AND and OR, compared with a value or with another column, and related tables — whether a related record exists, or one matching conditions of its own. Only the columns and related tables the user may read are offered, and the server refuses a filter on anything else. The user's filters last while the grid shows the view: another view starts from its own.

Filtering the Sample Contacts

Press the Filter button on the toolbar. The dialog opens on the filters of the view the grid shows. All Contacts has none of its own — the contact table's row security already keeps every query to the contacts you may read — so it opens empty, ready for yours. Contacts at Companies with a City keeps those whose company has a city, through a related table with a condition of its own. Change them, press Apply, and the grid shows the rows that match from the first page, its Filter button filled to show the filters are yours. Things to try:

  • Open a column's menu — the arrow in its header — and choose Filter by to filter on that column alone: a value it equals to start with, or the day for a date. Its header shows a filter icon while the rows are filtered on it, and the condition is there with the rest in the Filter dialog. Clear filter, in the same menu, takes it away.
  • Add a row and pick a column, an operator and a value — Contains a few letters of a name, say, or an age greater than 40. The value editor follows the column: a date picker for a date, a list for a choice, a record picker for a lookup.
  • Add a group to combine conditions under Match any (OR) or Match all (AND), nested as deep as you need.
  • Switch a row from By value to By column to compare two of the contact's columns.
  • Choose Add related entity and pick a relationship — the contact's company, say — then give it conditions of its own, or change Must have to Has no related row to keep the contacts with no such record, or to Has no matching row to keep those with none matching the conditions. Only the tables you may read are listed.
  • Open the dialog again and press Reset to view to go back to the view's own filters, or pick the other view, which starts from its own.
React example Blazor example React TypeScript Razor

A View That Filters on What the User May Not Read

Contacts of Active Owners keeps the contacts whose owner's user account is enabled, through a related table — system users — that the demo gives its visitors no access to. Rather than show every contact (the filter left out) or none (the related table matching no rows), the grid says which table it can't filter on, so the developer can give the users access to it or change the view. Open the Filter dialog and take the owner away to see the rows: the dialog shows the view's related table, but offers no system users to add. An internal user signed in to the demo, whose own Dataverse security roles decide what they read, sees the rows.

React example Blazor example React TypeScript Razor