Customized filters examples

Standalone Filter Example

Say you don't need to have a filter field in the each table column or the requirements says that search field should be placed outside of the table?
Fortunately this is super easy to achieve, to do this we need to slightly modify our basic component example.

Data Source

First thing you need to know is that all the data operations against the table must be done using the DataSource table property. DataSource is an abstraction around your data which allows you easily modify the table data or subscribe to events to modify the table behaviour.

To access the DataSource we either can take it from the table or pass it instead of our data array. Let's do the second option as it requires less code and is more demonstrative. Let's import the DataSource class by modifying the import statement:

  {{ snippets.sourceRequire }}

Note that the import now contains a LocalDataSource class (the word Local here means that the data is processed locally in a browser, not on the server side).
Then let's create a DataSource instance and pass our data array into it as a constructor parameter:

  {{ snippets.createSource }}

Now let's pass the source to the table instead of the data array:

  {{ snippets.sourceTemplate }}

At this point if you look at the result there will be no difference comparing to the first example. Basically if you pass an array to the table component first thing it will do is wrap LocalDataSource object around your array as we did here manually.
Now, having the DataSource we basically could change the table data in any way we need to - filter it, sort, paginate to some page, create/delete/modify the rows. In our example we need to be able to filter the data outside of the table, firstly let's add a search filed to the template with a listener:

  {{ snippets.search }}

And the listener code which asks the DataSource to filter the data:

  {{ snippets.searchTable }}

Last thing, let's hide the default table filters to not conflict with our standalone one:

  {{ snippets.hideFilters }}

And done! Now the table has a standalone search field:

Same way you can modify the data of the table, for example by adding a row from a third party form or listening to some external event. Here's a full component code:

  Demo Source
  {{ snippets.sourceFull }}

Checkbox, Select and Completer filter types

An example on how to use the built-in column filter types:

Demo Source