Source Filters

Source filters determine which records appear in your elements, allowing you to customize what information your users see.

What You'll Learn

You'll discover how to use Knack's updated filter system to precisely control which records appear in your elements. This knowledge will help you create more targeted interfaces that show exactly the information your users need, making your app more intuitive and effective.

Source Settings Overview

All elements indicate which records are being shown in the element editor. For elements that display multiple records, you can customize exactly which records appear.

In the "Source" tab within the element's settings, you have options to add filters that determine which records are shown and how they're displayed. By default, elements will display every record from the selected table if no filters are applied.

The Source tab has three main sections:

  • Data: Add filter groups and conditions to define which records will be displayed
  • Sort: Define the sort order for displayed records
  • Limit: Set a maximum number of records to show (e.g., showing only the top 10 products)

Understanding Data Source Filters

The Data section indicates which table's records the element is displaying. Here, you can create filter groups that restrict which records from that table will appear.

These filters allow you to match specific field values and apply these filters in logical groups.

How the New Source Filters Work

Basic Structure

The updated filtering system uses a more consistent and intuitive approach:

  • Each filter group contains one or more conditions
  • Conditions within a group work together (ALL must be true)
  • Different groups provide alternatives (ANY group can be true)

This approach is called "OR of ANDs" - within each group, conditions are connected by AND, while between groups, the connection is always OR.

Elements Using the New Filter System

The updated filter system applies to:

  • Table/Grid Source Filters
  • List View Data Source Filters
  • Pivot Tables
  • Bar Charts
  • Pie Charts
  • Line Charts
  • Area Charts
  • Map elements
  • Search elements
  • Calendar elements

Creating Filter Groups

To add your first condition to an element:

  1. Select the "Filter Records" button in the Source tab
  2. Choose a field from the dropdown
  3. Select an operator (depends on the field type)
  4. Enter a value if required

Adding Multiple Conditions

When you need more complex filtering:

  1. Click "+ Filter" to add another condition within the same group (all conditions must be true)
  2. Click "+ Filter Group" to create a new alternative group (any group can be true)

Example Filter Scenarios

Scenario 1: Show Open Troubleshooting Requests

To display all open Service Requests where the services needed are "Troubleshooting and Repair":

Create a single filter group with two conditions:

  • Status equals "Open"
  • Services Needed equals "Troubleshooting and Repair"

This means records must match BOTH conditions to appear.

Scenario 2: Show Multiple Service Types

To display Service Requests for either "Troubleshooting and Repair" OR "Software Installation":

Create two filter groups:

  1. First group: Services Needed equals "Troubleshooting and Repair"
  2. Second group: Services Needed equals "Software Installation"

This means records matching EITHER condition will appear.

Scenario 3: Complex Filtering

To show all open Service Requests that have Services Needed of either "Troubleshooting and Repair" OR "Software Installation":

Create two filter groups:

  1. First group:
    • Status equals "Open"
    • Services Needed equals "Troubleshooting and Repair"
  2. Second group:
    • Status equals "Open"
    • Services Needed equals "Software Installation"

Filter Update Required

When to Update Your Filters

  1. Navigate to your element's General tab
  2. If you see a warning about source filters, you'll need to make updates
  3. Click "Edit Source Filters" to begin

Step-by-Step Update Process

  1. Access your element and open the General tab
  2. Click "Edit Source Filters" if you see a warning
  3. Create your first filter group:
    • Choose your first field and value
    • Click "+ Filter" to add another condition within this group
  4. Add additional groups:
    • Click "+ Filter Group" to create a new group
    • Set up the conditions for this group
  5. Save your changes:
    • Review your filter groups to ensure they match your logic
    • Click "Apply" in the modal
    • Save the page to preserve your changes

Sorting Records

Sorting determines the order in which records will be displayed. You can sort on most fields in ascending or descending order.

You can also add multiple sort rules if needed. For example, you might sort Service Request records chronologically from oldest to newest:

Notes & Troubleshooting

  • Table sorting preferences do not apply to records displayed in an element. You can set a grid's sort order in the grid's settings in the Data section of the Builder.
  • Tables' sort order applies to records displayed in connection field dropdowns and the tables' record view in the Data section of the Builder.
  • When thinking about your filter logic, consider:
    • "Either/or" scenarios become separate filter groups
    • Conditions that must ALL be true go within the same group
    • Multiple groups represent alternative ways to match records
  • Always test your filters to ensure they show the expected records