Masking MasterFields/DetailFields

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Anachronox
Posts: 11
Joined: Sun 30 Mar 2014 11:53

Masking MasterFields/DetailFields

Post by Anachronox » Thu 23 Oct 2014 13:49

Hello.

I've created my own TVirtualTable descendant, where I need to "redefine" MasterFields and DetailFields properties, among others.

These are published in TVirtualTable and defined in TMemDataSet as protected.

So I redefined them in my descendant /as published/ including my own setters and getters for both.

But their setters and getters didn't work in Object Inspector. After filling any value in design-time, the field was filled back to empty string after click to other property.

So I decided to add one more class, just to hide both properties (state them as private).

So my code looks as follows:

Code: Select all

  
  TCustomVirtualTable = class(TVirtualTable)
  private
    property MasterFields; // Hide published
    property DetailFields; // Hide published
  end;

  TMyVirtualTable = class(TCustomVirtualTable)
  private
    function GetMasterFields: String;
    function GetDetailFields: String;
    procedure SetMasterFields(Value: String);
    procedure SetDetailFields(Value: String);
  published
    { Redefine Hidden Properties }
    property MasterFields: String read GetMasterFields write SetMasterFields;
    property DetailFields: String read GetDetailFields write SetDetailFields;
  end;
It is working now, but still I can see special property editor for both in Object Inspector.

So is this the right way to redefine/mask published properties and how can I get rid of these editors ?

Thank you for your help.

Anachronox
Posts: 11
Joined: Sun 30 Mar 2014 11:53

Re: Masking MasterFields/DetailFields

Post by Anachronox » Thu 23 Oct 2014 22:34

What I've found, editor type for this two properties is TLinkFields ("Field Link Designer"), the standard Delphi property editor. But I can't see it anywhere in the source (no RegisterPropertyEditor, etc.). The only place where I see something similar is dcldac200.bpl, the phrase "DADataSetMasterFieldsEditor", so probably the registration is out there, but only compiled, without source.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Masking MasterFields/DetailFields

Post by AlexP » Fri 24 Oct 2014 08:42

Hello,

To replace the Maser/Detail field editor, you should register new editors in the Register method of your component, for example:

Code: Select all

procedure Register;
begin
  RegisterComponents('Samples', [TMyVirtualTable]);
  RegisterPropertyEditor(TypeInfo(string), TMyVirtualTable, 'MasterFields', TStringProperty);
  RegisterPropertyEditor(TypeInfo(string), TMyVirtualTable, 'DetailFields', TStringProperty);
end;
When using TStringProperty - the property in the object inspector will be a simple string.

Anachronox
Posts: 11
Joined: Sun 30 Mar 2014 11:53

Re: Masking MasterFields/DetailFields

Post by Anachronox » Fri 24 Oct 2014 12:51

Thank you Alex, exactly what I was looking for!

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Masking MasterFields/DetailFields

Post by AlexP » Mon 27 Oct 2014 05:31

You are welcome. Feel free to contact us if you have any further questions.

Post Reply