There are three ways to add indexes to a client dataset:
Methods |
Description |
Use the IndexFieldNames property |
To create a temporary index at runtime that sorts the records in the client dataset, you can use the IndexFieldNames property. Specify field names, separated by semicolons. Ordering of field names in the list determines their order in the index. This is the least powerful method of adding indexes. You can't specify a descending or case-insensitive index, and the resulting indexes do not support grouping. These indexes do not persist when you close the dataset, and are not saved when you save the client dataset to a file. |
Call AddIndex |
To create an index at runtime that can be used for grouping, call AddIndex. AddIndex lets you specify the properties of the index, including: The name of the index. This can be used for switching indexes at runtime. The fields that make up the index. The index uses these fields to sort records and to locate records that have specific values on these fields. How the index sorts records. By default, indexes impose an ascending sort order (based on the machine's locale). This default sort order is case-sensitive. You can set options to make the entire index case-insensitive or to sort in descending order. Alternately, you can provide a list of fields to be sorted case-insensitively and a list of fields to be sorted in descending order. The default level of grouping support for the index. Indexes created with AddIndex do not persist when the client dataset is closed. (That is, they are lost when you reopen the client dataset). You can"t call AddIndex when the dataset is closed. Indexes you add using AddIndex are not saved when you save the client dataset to a file. |
Use the IndexDefs property |
The third way to create an index is at the time the client dataset is created. Before creating the client dataset, specify the desired indexes using the IndexDefs property. The indexes are then created along with the underlying dataset when you call CreateDataSet. See Creating and deleting tables for more information about creating client datasets. As with AddIndex, indexes you create with the dataset support grouping, can sort in ascending order on some fields and descending order on others, and can be case insensitive on some fields and case sensitive on others. |
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|