Skip to content

Filtering SharePoint drop-down menu

The SharePoint data component is a powerful component that can be user to show data coming from any datasource. However data sources often contain thousands of rows which means it can be helpful to filter this data so that users can see whats most important. You can do so using the steps below:

  1. Navigate to the data tab of the component settings

  2. Under the advanced settings you should see a “Filter Query” option which will accept a Javascript expression to filter components by

Type an expression based on the structure on the structure of the data from your SharePoint data source. In the example below we have a list of vehicles with multiple columns and will filter the list for only a specific make (Ferrari). The Sample Item field is a good reference to show what fields to reference in your expression.

show = item.Make === 'Ferrari'

Its important to note the capitalisation if the fields used by your data source as the JavaScript expression is case sensitive.

The code will run your expression for every row in your data source to determine weather it should appear in the drop-down menu. From the example above a few variables are reference which are described below.

VariableDescription
showAssign true or false to control whether the current row appears.
itemThe current source row. Use exact, case-sensitive paths from Sample Item, such as item.FieldName.
dataCurrent form answers, which can be used for cascading or context-dependent filters.

The expression runs before the component applies sorting, the Fields projection, and duplicate removal. See the data-source component schema reference for the complete processing order.