Skip to content

WTable filtering

marksreeves edited this page Dec 21, 2015 · 1 revision

This is an outline of one approach to creating a filter for WTable which is based on the content of a given column. It is not prescriptive and there are other approaches.

Filtering a table to show only those rows which have one or more particular value(s) in a specific column is a common task. It is not a task which is conducive to a purely client side mechanism since the entire table content may not be available (due to pagination, row expansion etc).

Define your parameters

Before building a filter one must know what is to be filtered (the table column/s) and what constraints will be placed on the filters, such as whether the filtering should allow multiple selection. In this simple walk-through we will demonstrate single value filtering in a single column, it is easy to extend this.

Filter using WMenu

The filtering is done on the server and is instigated using WMenuItems in a WMenu of Type FLYOUT. This WMenu has a single child which is a WSubMenu. The WSubMenu's labelling component contains a WImage (showing a filter) with alt property set appropriately.

This WMenu is added to the table column header after the column description text.

The final WTable will look something like the illustration below.

Example table with filterable columns

With one of the filter menus open the table may look like the following:

Example table with filterable columns open menu

After the filter is applied (assume choose surname Starkey) we then have:

Example table with filtered column

Improving performance with AJAX

The filtering will currently cause a complete page reload, which is excessive. To improve the performance the WMenuItems can be WAjaxControls with the WTable as the target for each. This will result in only the table being reloaded to change the filter.

Clone this wiki locally