TDAMemDataTable filters (Delphi)
To create a filter using the Filter property, set the value of the property to a string that contains the filter's test condition. For example, the following statement creates a filter that tests a dataset's State field to see if it contains a value for the state of California:
table.Filter := 'State = ' + QuotedStr('CA');
You can also supply a value for Filter based on text supplied by the user. For example, the following statement assigns the text from edit box to Filter:
table.Filter := Edit1.Text;
You can, of course, create a string based on both hard-coded text and user-supplied data:
table.Filter := 'State = ' + QuotedStr(Edit1.Text);
After you specify a value for Filter, to apply the filter to the TDAMemDataTable, set the Filtered property to True.
Filters can compare field values to literals and to constants using the following comparison and logical operators:
Boolean operators
Tests two statements that both have to be True | ||
Tests one statement that has to be not True | ||
Tests that at least one of two statements is True | ||
Tests that at least one of two statements is not equal to the other one |
Comparing operations
Less than | ||
Greater than | ||
Greater than or equal to | ||
Less than or equal to | ||
Equal to | ||
Not equal to | ||
Test values for NULL | ||
Test values for NOT NULL | ||
Tests values from specified list | ||
Finds a string fitting a certain description | fld1 LIKE '%a' |
Logical operators and math symbols
bitwise and | ||
bitwise negation | ||
bitwise or | ||
bitwise xor | ||
addition | ||
subtraction | ||
multiplication | ||
real division | ||
modulus | ||
specifies that value in hex format |
Wildcards for partial comparisons for LIKE operator
By using combinations of these operators, you can create fairly sophisticated filters. For example, the following statement checks to make sure that two test conditions are met before accepting a record for display:
(fld1 > 1400) AND (fld1 < 1500)
When filtering is on, user edits to a record may mean that the record no longer meets a filter's test conditions. The next time the record is retrieved from the TDAMemDataTable, it may therefore "disappear." If that happens, the next record that passes the filter condition becomes the current record.