Recent

Author Topic: Standard Dataset Actions  (Read 22988 times)

rvk

  • Hero Member
  • *****
  • Posts: 6806
Re: Standard Dataset Actions
« Reply #30 on: August 11, 2014, 08:44:04 pm »
I don't know how Delphi did this "magic", but I can assure you it worked and it is one that I'll really miss in Lazarus.
taazz already explained how Delphi could do (or does) this. You could try to mimic this behavior yourself by adding some code (like Delphi does) to detect the datasource of the current control.

You could use an event (OnActiveControlChange for example, if Lazarus has this one) and check if the ActiveControl has a property "DataSource". If it does you could set the DataSource of all your TDataSetAction on your form to that same DataSource (it would be just a few lines of code in the OnActiveControlChange-event). All this is assuming you have an activecontrol with a datasource. What if the activecontrol does not have a datasource? How does Delphi handle that? If there are multiple datasources on a form and your control is on a non-data-aware control.... what datasource does Delphi take then? (so many possibilities...)

Otherwise you could use the method i showed you in the last procedure of my post.
You could even create a generic procedure to use in different programs.
(For the program you showed it was just a few lines needed to be added)

It can't be helped that Lazarus/FPC sometimes behaves slightly differently (it's not a direct clone). Sometimes these differences are deliberate (to not blindly follow Delphi in bad design/programming) and sometimes it is unintentional (or just a bug). In case it is unintentional (or a bug) you could try to code new features or patch Lazarus/FPC and see if these changes are of benefit to others. If others find the code useful it can be added to the next release.

In this case you stumbled on a (rarely used) "missing feature". You could try adding an entry in the bugtracker to see if it is deemed important enough (for others) to fix (or attach the fix yourself).
« Last Edit: August 11, 2014, 08:47:38 pm by rvk »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Standard Dataset Actions
« Reply #31 on: August 13, 2014, 07:11:54 am »
I took a closer look on the delphi action implementation and as far as I can see the magic is in the TDBEdit.ExecuteAction and TDBEdit.UpdateAction (and other data aware controls) which has been extended to call the FDatalink.ExecuteAction as well.

I do not know how I fill about it. It gives the most control over to the control designer and at the same time it forces code duplication on all the data aware controls.

In the bright side it is easy to correct and the TDatalink seems to already have the action methods implemented.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018