| View previous topic :: View next topic |
| Author |
Message |
Fernando Guest
|
Posted: Tue Aug 26, 2003 7:19 pm Post subject: Sorting with IndexName property |
|
|
I'm having some problems trying to apply a new sort field in a
existing IndexDef.
I have a IndexName called idxMySort sorting the dataset (TClientDataSet)
by 'Code' (idxMySort.Fields = 'Code') and I want to change the
sort order to 'Name', putting in the Fields property the
value 'Name' (idxMySort.Fields = 'Name'). The new sort order is
only applyed after I close and reopen the DataSet. I need to
know the best way to do it, without using close and open (wich
is too slow).
I have posted this question in ADO newsgroup and I've got no answer...
Thank's in advance.
Fernando
|
|
| Back to top |
|
 |
Bill Todd Guest
|
Posted: Tue Aug 26, 2003 9:59 pm Post subject: Re: Sorting with IndexName property |
|
|
I am having some trouble understanding your message. If you have two
indexes, one named CodeIndex and one named NameIndex all you have to
do is:
ClientDataSet1.IndexName := 'CodeIndex';
ClientDataSet1.IndexName := 'NameIndex';
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
| Back to top |
|
 |
Fernando Guest
|
Posted: Tue Aug 26, 2003 10:27 pm Post subject: Re: Sorting with IndexName property |
|
|
I have only one index, named 'GenericIndex'. The initial state
of this index is sort by 'Code' field (setting the Fields
property to 'Code'). Now I want to sort the DataSet by 'Name'
using the same index ('GenericIndex'), setting the Fields
property to 'Name' (the old Fields property value, that
was 'Code', now is changed to 'Name'). But the new sort is not
applyed until I close and reopen the DataSet.
// initial state of index is sorted by 'Code'
GenericIndex.Fields := 'Code';
// the DataSet is indexed by 'GenericField' and ordered
// by 'Code'
DataSet.IndexName := 'GenericIndex';
// now I change the Fields property to 'Name' to sort
// by 'Name', but the dataset donīt change the order.
GenericIndex.Fields := 'Name';
I need refresh the sort order of dataset when I change the
Fields property to new FieldName, without changing the
IndexName property of DataSet to other index. Is there any way
to do it?
Thank you very much...
P.S. Sorry about my english, I'm Brazilian....
|
|
| Back to top |
|
 |
Bill Todd Guest
|
Posted: Wed Aug 27, 2003 12:59 am Post subject: Re: Sorting with IndexName property |
|
|
Then why use an index at all. Just assign the field name to the
IndexFieldNames property.
If you do decide to use indexes you must use two indexes to be able to
change them quickly at runtime.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
| Back to top |
|
 |
Fernando Guest
|
Posted: Wed Aug 27, 2003 10:54 am Post subject: Re: Sorting with IndexName property |
|
|
IndexFieldNames donīt accept descending sort order... :(
Creating dinamically indexes at run time affect the performance of dataset?
Thanks...
Fernando
Bill Todd <no (AT) no (DOT) com> wrote:
| Quote: | Then why use an index at all. Just assign the field name to the
IndexFieldNames property.
If you do decide to use indexes you must use two indexes to be able to
change them quickly at runtime.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
|
| Back to top |
|
 |
Bill Todd Guest
|
Posted: Wed Aug 27, 2003 3:01 pm Post subject: Re: Sorting with IndexName property |
|
|
On 27 Aug 2003 03:54:45 -0700, "Fernando" <fernando (AT) headsoft (DOT) com.br>
wrote:
| Quote: | Creating dinamically indexes at run time affect the performance of dataset?
|
Not if the number of records is a few thousand or less.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
| Back to top |
|
 |
|