This topic describes how to use a data filter in details. You can create a filter, add a filter, sort filters, and create a code snippet.
Create a filter
You can create a filter by using one of the following methods:
- Click the Data Filter icon.
- On the editor toolbar, click the Data Filter icon.
- In the Data Filter pane, click New Filter.
- In the filter edit box, specify a name for the filter and enter the filter code. Then,
click Save.The created filter appears in the list.Notice The filter you created by using the Data Filter icon on the toolbar can be called by all widgets in the project. For more information, see Use the data filter. When a filter is called, you can view the dependency between the widget and the filter.
- On the editor toolbar, click the Data Filter icon.
- Create a filter in the Set Data Source pane of the widget.
- Add a widget to the project and click the Data tab of the right-side panel.
- On the Data tab, select Data Filter and click Add Filter.
- In the Set Data Source pane, click + on the right of Add Filter.
- In the filter edit box, specify a name for the filter and enter the filter code. Then, click Save.
The created filter appears in the list. You can view the dependency between the widget and data filter.
Rename a filter

Delete a filter

Add a filter
Sort the filters
After you add multiple filters to a widget, you can drag and drop the filters to sort them.
If multiple filters are added to a widget, they filter the widget data in sequence from the top down. The input of the first filter is the data returned by the data source, the input of the second filter is the output of the first filter, and so on.
- If one of the filters returns null, this filter is ignored, and the data filtering continues. The system prompts that the output of this filter is null when you configure the filters.
- If one of the filters encounters an error, the data filtering stops, and the last correct filter result is used.
Debug a filter
Data source and filter errors
- Data source error: After you add a filter to a widget on the Data tab, if you change the data source
type, two errors are reported, prompting that the data source is abnormal.Notice When the data source is abnormal, the data it returns is incorrect. Therefore, the data filter does not filter data and is dimmed on the Data tab.
- Filter error: If the filter encounters an exception when it filters data, an error is reported
in both the filter and the filter output.
Figure 1. Error in the filter Figure 2. Error in the filter output
Manage the Data Filter pane

Create and import a code snippet
You can create a code snippet from a filter and import the code snippet to the filter. This allows you to call the filter across projects.