Displaying and Editing a Subset of Data Using Filters
Go Up to Understanding Datasets Index
An application is frequently interested in only a subset of records from a dataset. For example, you may be interested in retrieving or viewing only those records for companies based in California in your customer database, or you may want to find a record that contains a particular set of field values. In each case, you can use filters to restrict an application's access to a subset of all records in the dataset.
With unidirectional datasets, you can only limit the records in the dataset by using a query that restricts the records in the dataset. With other TDataSet descendants, however, you can define a subset of the data that has already been fetched. To restrict an application's access to a subset of all records in the dataset, you can use filters.
A filter specifies conditions a record must meet to be displayed. Filter conditions can be stipulated in a dataset's Filter property or coded into its Data.DB.TDataSet.OnFilterRecord event handler. Filter conditions are based on the values in any specified number of fields in a dataset, regardless of whether those fields are indexed. For example, to view only those records for companies based in California, a simple filter might require that records contain a value in the State field of "CA".
Note: Filters are applied to every record retrieved in a dataset. When you want to filter large volumes of data, it may be more efficient to use a query to restrict record retrieval, or to set a range on an indexed table rather than using filters.
Topics
- Enabling and Disabling Filtering
- Creating Filters
- Setting Filter Options
- Navigating Records in a Filtered Dataset