Filter the Data in a Grid

SAIL Recipes give you an opportunity to explore different interface design patterns. To learn how to directly use SAIL recipes within your interfaces, see Adapt a SAIL Recipe to Work with My Applications.


Filter the data in a read-only paging grid using a dropdown. When the user selects a value to filter by, update the grid to show the result. The result displays on page 1 even if the user was previously on a different page number.

This recipe uses an employee data structure and objects created through the Use the Write to Data Store Entity Smart Service Function on an Interface recipe. Make sure that recipes has been built first in order to see data in this recipe.


This design pattern is not recommended for offline interfaces because reflecting immediate changes in an interface based on user interaction requires a connection to the server.

This scenario demonstrates:

  • How to change the value of a variable when the user updates another variable
  • How to ignore the value returned by the component and update a variable with a literal value


  /* In a real app, these values should be held in the database or in a constant */
  local!departments: { "Corporate", "Engineering", "Finance", "HR", "Professional Services", "Sales" },
  local!pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 5,
    sort: a!sortInfo(
      field: "id",
      ascending: true
    * local!datasubset is pulling data from the employee data store entity 
    * from the entity backed record tutorial.
    * To use your data, change the constant from cons!EMPLOYEE_ENTITY to one of
    * your own. Then replace the fields in the queryColumns to a
    * relevant datapoint from your data store entity
    local!datasubset: a!queryEntity(
        selection: a!querySelection(columns: {
          a!queryColumn(field: "firstName"),
          a!queryColumn(field: "lastName"),
          a!queryColumn(field: "department"),
          a!queryColumn(field: "title"),
          a!queryColumn(field: "phoneNumber"),
          a!queryColumn(field: "startDate")
        filter: if(
          a!queryFilter(field: "department", operator: "=", value: local!selectedDepartment)
        pagingInfo: local!pagingInfo
          choiceLabels: local!departments,
          choiceValues: local!departments,
          placeholderLabel: "-- Filter By Department -- ",
          totalCount: local!datasubset.totalCount,
          columns: {
              label: "First Name",
              field: "firstName",
              data: index(local!, "firstName", null)
              label: "Last Name",
              field: "lastName",
              data: index(local!, "lastName", null)
              label: "Department",
              field: "department",
              data: index(local!, "department", null)
              label: "Title",
              field: "title",
              data: index(local!, "title", null)
              label: "Phone Number",
              data: index(local!, "phoneNumber", null)
              label: "Start Date",
              field: "startDate",
              data: index(local!, "startDate", null),
              alignment: "RIGHT"
          value: local!pagingInfo,
          saveInto: local!pagingInfo

Test it out

  1. Select a department from the dropdown to filter the grid. Notice that employees from only one department is visible in the grid.
  2. Select "Filter By Department" from the dropdown. All employees will return to the grid.

Notable implementation details

  • Notice that when the user makes a selection from the dropdown, we’re always resetting the value of local!pagingInfo so that the user always sees the first page of results for the selected filter. This is necessary regardless of what the user has selected, so we ignore the value returned by the component (in this case, the value of the dropdown selection) and instead insert our own value.
  • When you configure your grid, replace the value of local!data with the result of your a!queryEntity() or queryrecord(). These functions allow you to retrieve only the fields that you need to configure your dropdown. See also: SAIL Design
  • When using a!queryEntity() or queryrecord(), you can remove the filtering step and simply use a filter within a!queryEntity() or queryrecord() itself. For examples, see Query Recipes.