New Behavior of SortType

In this forum all bug reports concerning the 6.x branch will be gahtered. You have the possibility to track the bug fix process.

Moderators: EgonHugeist, mdaems

bangfauzan
Senior Boarder
Senior Boarder
Posts: 50
Joined: 31.08.2006, 10:41
Contact:

New Behavior of SortType

Postby bangfauzan » 27.11.2006, 05:48

Hi All,

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;

Modified to:

Code: Select all

property SortType : TSortType read FSortType write SetSortType
      default stAscending;

Before the change, if SortedFields contained multiple fields, the value of SortType always stIgnored, coz of GetSortType code which automatically called when IndexFieldNames changes. After the modification, the problem was solved.

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
You do not have the required permissions to view the files attached to this post.

User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Postby mdaems » 27.11.2006, 23:59

This new version has been added to SVN testing branch (rev 185). In about a week it will be moved to trunk.

Mark


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 1 guest