How to filter table rows using the data source user parameters

Sometimes, you want to view just a portion of the table rows based on certain criteria. If these criteria are known beforehand, there is no need to use a front-end dynamic filter but instead you should use server side filtering. In this article we discussed on way to do that.

Let's assume that you have a list of books for many authors, but you want to display for each author only the books written by this particular author. The book list is stored in a CSV file with the following contents:

Book title,Author,Year
Title 1,Author 1,2000
Title 2,Author 1,2003
Title 3,Author 2,2003
Title 4,Author 2,2006

We want to create two pages, one for Author 1 and another one for Author 2. In order to do so we will create a single data source with the following settings:

The ruleset must contains one rule that calls the modification function filterbyparam which is responsible for filtering the table rows based on the given data source user parameter. Here are the settings used in this example:

Element: Table
Range: all
Table/Modify
Function Name: filterbyparam
Function Args: {user_param_1:text},2,1,0

The filterbyparam takes the following arguments:

filter value,column index,top header rows,bottom header rows

Notice how we specified the filter value. Instead of a fixed value, we use the data source user parameter 1 which will be provided when inserting the data source into the article. The top headers and the bottom header rows will be ignored during the filtering process.