Page 1 of 2

[bug_fixed] New Feature: LinkedFieldNames Vs IndexFieldNames

Posted: 09.10.2006, 02:07
by bangfauzan
Dear Zeos Team

I did some changes of the original IndexFieldNames property to be LinkedFields property for conducting master-detail relationship. After this change, Old code still 100% work without remapping every call to IndexFieldNames to LinkedFields (as mdeams whishes). And I added a new IndexFieldNames property for sorting purpose, conforming to IndexFieldNames property of ADO dataset. Consequently, sorting data can be conducted by either IndexFieldNames property or combination of SortedFieldNames and SortType properties. By entering certain value (corresponding name of one or more fields of dataset) into one of the three properties, other property automatically make synchronization.

Suppose we want to sort data by e.g. FirstName in ascending order, we can either enter or select from list FirstName field via SortedFields property and set SortType property to be stAscending, and then the value of IndexFieldNames would be automatically “FirstName Asc”. Or we can enter “FirstName Asc” into IndexFieldNames property, so SortedField and SortType will be FirstName and stAscending.

Don’t worry about compatibility, it fully compatible. For all other user that were using IndexFieldNames as master-detail relationship, they just have to make little bit modification by moving the value of old Indexfieldnames property into LinkedFields, or by replacing their code corresponding IndexFieldNames by LinkedFields if they were making master-detail relationship programmatically, and everything will work properly. I have made very hard testing and I have used it in production purpose and everything looks good.

If we use TUltimGrid from JEDI, and we set its TitleButton property to True, in run time we can make sorting for each fields just by pressing any title of its columns.

Finally, if the members of this forum can accept these changes, I wish it will be added to the SVN project repository.

Note:
In these changes, also contain previous addition and modifications, thus are:
- BeforeApplyUpdates event
- AfterApplyUpdates event
- SortType property
- EmptyDataSet method
- InternalPost bug-fix
- InternalPost modification

Under construction: ChangedCount property.

Thanks a lot.

Bangfauzan (Fauzan Badriawan Madura Indonesia)

Posted: 10.10.2006, 01:56
by bangfauzan
Dear Zeos Team,

What is your opinion about these changes?

Thanks

Posted: 10.10.2006, 07:56
by mdaems
Michael confirmed we should put it in. (Unless there are problems during integration/test)
Probably I'll try to do it tomorrow.

Any objections??

Mark

Posted: 10.10.2006, 08:28
by bangfauzan
No objection, Thanks Mark!

Fauzan

Posted: 10.10.2006, 20:46
by mdaems
Committed in SVN Rev 111. I hope nobody kills me because of that.
... Oops ...
Maybe Lazarus People will do. You put some new code in and IFDEFed part not compiled in Lazarus.
Fixed (I hope).
Please confirm if this version works like expected.

Mark

Posted: 11.10.2006, 02:25
by bangfauzan
Oooops......
I did not try that on lazarus, I would do any test (and modification if necessary)
and I will confirm you later.

thanks

Posted: 12.10.2006, 07:10
by fduenas
I only have opne question?
Sorry if it a late question but...
why change the name for indexfieldNames to linkedFields, i thought IndexFieldNames property names whas supossed to be like this to preserve similarity to TTable or any other TDataset that mananges Master-datail relationship. The property that is supposed to contain the link is masterfields property. then indexfielnames should contain the fields to select a desired index to make the Master-detail relationship.

What are the advantages for the new modification?

Sorry but still not understand..

Posted: 12.10.2006, 08:45
by bangfauzan
Your are right, other components use IndexFieldNames as master-detail relathionship. But we have to notice that in other components, IndexFieldNames handling both master-detail relathionship and data sorting as well. while zeos was absolutely different, whereas zeos uses indexfieldnames for master-detail relationship only, while data ordering handled by sortedfields property.

After the changes, MasterFields still being uses for pointing the key field within master dataset, and 'old/original' indexfieldnames which was replaced by LinkedFields for pointing field on detail dataset that linked to the masterfields. and then 'new' IndexFieldNames added for sorting purpuse.

so now, there are:
- MasterFields and LinkedFields (for master-detail)
- IndexFieldNames (ordering data)
- SortedFields and SortType combination (ordering data as alternative)

I think this much closer in similarity and/or characteristic compliance of other components.

I wish you can capture the point, becouse my english is not good enough.

Best Regars

Posted: 12.10.2006, 08:57
by mdaems
@Fduenas,
Do you mean we should undo the whole thing or rename some properties? I agree we should keep functionallity of equally named properties similar to standard Delphi components. I only don't know much about master-detail stuff, so can you check if new version works like before (or like it does with standard components if that was different before).

@bangfauzan:
Maybe UltimGrid code should be changed? Does it work with normal Delphi components?

Mark

Posted: 12.10.2006, 10:32
by bangfauzan
Dear mdeam

UltrimGrid works very well on other standard components.
But if changing the indexfieldnames property makes zeos people facing 'contra'
may be it is much more wise if I cancel/abort the change, except previous changes like BeforeApplyUpdates, EmptyDataSet, etc. But I hope everybody doing test of these changes before they accept or reject the change.

I will try to change ultimgrid code as you suggest.

Thanks for all

Best Regards.

Posted: 12.10.2006, 13:10
by mdaems
Halt!!!! Wait !!!!!
There must be a reason why it works on other standard components and not on zeos.
We have to find out this difference and how we can get Zeos closer to standard behaviour.
Some input from others, please. I can undo your (relatively small) patch any time later on, so let's not hurry too much.

Mark

Posted: 13.10.2006, 04:07
by bangfauzan
Ok, I see.

Thanks Mark.

Regards

Posted: 13.10.2006, 04:16
by bangfauzan
Hi, Mark

I have changed UltimGrid code to comply old zeos (before renamed IndexFieldNames) behavior. It is very simple, I just redirect IndexFieldNames to SortedFields. And... everything work fine. But when I use other standard component, it doesn't work, because no SortedFields property in other component. All others always use IndexFieldNames in performing sorting beside as master-detail relationship.

So I undo all of changes in ultimgrid code.

Regards.

Posted: 13.10.2006, 14:34
by gto
Hello people!
Some ideas: I've never used the "old" IndexFieldNames for master detail relationship.
This post explain the method I use, which, from my view, is quite more "clear".

I know that IndexFieldNames is used in TTable for master/detail and should confuse some people that migrate directly, but dunno if it's really needed to be compatible. The use of IndexFieldNames only for indexing, looks, to me, right. If you look in TQuery, it doesn't have IndexFieldNames but have a Dataset property. I think borland support the method of master/detail using Dataset and field name as param into SQL query.

Posted: 13.10.2006, 14:40
by fduenas
@bangfaunzan: yes i got your point, i was only worried it could alter normal behaviour for other delphi components.

Here are my 2 cents:

Hi, Maybe we can make both things work, preventing to alter compatibility with other components, and to add new bejaviour for special stuff, like bangfauzan's example.

Maybe if we hadd a new option to the TZQuery.options set
like opUseLinkedFields, so if option is set to false it will work as normal, and if set to true will work as bangfauzan modified. Don't know how much difficult could be, maybe is the best solution for both cases.

So

@bangfaunzan: can you make the changes based in latest revision to it could be easily to mdaems to apply the patch?

@bangfaunzan, @mdaems, @all people:
What's you opinion? maybe is the best solution. but don't know if the name of opUseLinkedFields could be a correct name.

Maybe opUseNewLinkedFields or opUseLinkedFieldsProperty or opUseLinkedFieldsForMasterDetail. I know, I know, the last none was too large but was very clear :D