Σάββατο 15 Νοεμβρίου 2014

How to set up a filter expression for a View programmatically

To set up a filer programmatically, it's necessary to use the AddItem and AddItemList methods of the Data Controller's filter criterion.



The following example demonstrates how to set filter criteria for the following string:

 (CustNo < 1000) AND ((Name LIKE ‘A%’) OR (Name LIKE ‘Z%’)).

The colCustNo and colName objects are of the TcxGridDBColumn class. They identify the desired columns in a View.
To prevent the filter criteria from being updated every time a filter condition is added, operations are enclosed within the TcxFilterCriteria.BeginUpdate and TcxFilterCriteria.EndUpdate methods.

[Delphi]Open in popup window
var AItemList: TcxFilterCriteriaItemList; ... <DataController>.Filter.BeginUpdate; try <DataController>.Filter.Root.Clear; <DataController>.Filter.Root.AddItem(colCustNo, foLess, 1000, '1000'); AItemList := <DataController>.Filter.Root.AddItemList(fboOr); AItemList.AddItem(colName, foLike, 'A%', 'A%'); AItemList.AddItem(colName, foLike, 'Z%', 'Z%'); finally <DataController>.Filter.EndUpdate; <DataController>.Filter.Active := true; end;

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου