Adding Filters to Your QDataGrid

Now, we will add a filter bar to our datagrid.

Enabling the filter bar is as easy as setting the datagrid's ShowFilter property to true. Specifying the filters to use is all that's left.

While creating the datagrid's columns, you can also specify a filter to use for that column. These can either be custom filters for you to handle yourself, or QConditions (specifically, any QQConditionComparison) for your use with QQuerys. We'll be looking at the latter in this example.

So the first step is defining the filters. In this example, we set up an Equal filter for the Person Id and Like filters for the name columns. Note that if you just want to use the default filter for that database column's type, you can just use the node's SetFilteredDataGridColumnFilter function, as shown for the Last Name column.

Then, in our dtgPersons_Bind function we just make sure we use the conditions the datagrid provides us with. And there you have it, a filtered data grid.

But know what's even easier than that? The MetaDataGrids generated for you already include these filters by default! Any time you use MetaAddColumn, it will set any appropriate filters for that column without a single line of extra code on your part. :) See the Introduction to Meta DataGrids for more information.
Previous|1|Next Results: Viewing items 1-19 of 19.
Person ID First Name Last Name Sorted
3 Ben 5665564
1 kavita 2 arulyfred
9 Linda Brady
11 Brett Carlisle j
4 Mike Ho
14 sdhgfhsdg jai
17 good job
16 Nice Job
8 Samantha Jones
12 Jacob Pratt
2 Kendall2 Publics
13 sdf sdf
6 Wendy Smith
5 Alex Smith
10 Jennifer Smithfgfg
27 test test
22 moi tpo77
15 billy wilder
7 Karen Wolfe