Currently, SortedFields triggers the values of both IndexFieldNames and SortType. The IndexFieldNames and SortType depend each other, and it is actually a circular reference. The value of SortType depends upon the value of IndexFieldNames and then SortType triggers the value of IndexFieldNames.
Before I proposed the new behavior, here the history, to figure their behavior and changes.
Initially, SortType has only two values, stAscending and stDescending. The limition beside some bugs is we can only sort one or more fields in one order method.
And then I add new value of SortType named stIgnored, to eliminate the limitation, but with a bug (as mentioned by pawelsel).
There is a contradiction between my perceptions with what pawelsel perceives. In my perception, after stIgnored added, stAscending and stDescending used for sorting single field, while stIgnored used for sorting multiple fields with any order methods. That’s why I write code to remove anything behind space (and should be anything behind comma and semicolon as well; this was fixed).
In other hand, if I’m not wrong, pawelsel perceives, stAscending and stDescending should be used also in multiple fields. And I think, this is a reasonable perception. So I rework the code (some with pawelsel modifications) to make it more powerful in sorting capabilities.
Now I finished the work, with appropriate results. I also changed the property definition of SortType which previously defined as:
Code: Select all
property SortType : TSortType read GetSortType write SetSortType
default stAscending;
Code: Select all
property SortType : TSortType read FSortType write SetSortType
default stAscending;
Finally, I’ll talk about the new behavior of SortType. As I mentioned above, the current behavior of SortType and IndexFieldNames is a circular reference, which more complicated and more step needed by user in sorting data.
After the last discussion between pawelsel and me, and after a long consideration, I decide to change the behavior, yes, without circular reference, that means, SortedFields triggers value of IndexFieldNames only, and IndexFieldNames value still depends on both SortedFields and SortType values, while SortType is independent (not triggered by or depends on others).
Consequently, the first thing we have to do is setting SortType value manually, and then we set the SortedFields or IndexFieldNames value. Every entry of SortedFields and also IndexFieldNames will be checked previously and corrected automatically (if necessary) corresponding the value of SortType.
Example:
Suppose we have three fields to be sorted, thus CustName, City and Nation
A. If we want all field sorte ascendingly, by Nation, by City, by CustName the steps are:
- Setting SortType to be stAscending
- Typing "Nation;City;CustName" into SortedFields
then IndexFieldNames would be "Nation Asc;City Asc; CustName Asc"
B. If we want all field sorte descendingly, by Nation, by City, by CustName the steps are:
- Setting SortType to be stDescending
- Typing "Nation;City;CustName" into SortedFields
then IndexFieldNames would be "Nation Desc;City Desc; CustName Desc"
C. if we want to sort Nation Descendingly, City Ascendingly and CustName Acendingly, the steps are:
- Setting SortType to be stIgnored
- Typing "Nation Desc;City Asc;CustName Asc" into SortedFields
or just enter "Nation Desc;City;CustName"
then IndexFieldNames would be the same with SortedFields
Suppose we do example A or example C, and then we change SortType become stDescending, the IndexFieldNames would be like Example B.
Field separator can be either comma or semicolon.
Newest revisions attached below.
Great thanks to pawelsel who is intentionally and seriously involving him self in effort to make zeos better especially is regarding this matter.
Regards
Fauzan Badriawan