Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Dataset property of custom component
Sun, Dec 11 2016 4:07 AMPermanent Link

Uli Becker

As a newbie in creating custom components:

I created a component deriving from TBasicPanel. This component reads
the content of a TDataset and displays the records in some way.

This is the type declaration:

<Code>
   TPanelTabelle = class(TBasicPanel)
      private
         FFontName: string;
         FRowCount: Integer;
         FDataset: TDataset;
         procedure SetFontName(Value: string);
         procedure SetDataset(Value: TDataset);
         function GetFileNameWappen(FToken: string): string;
         function IsMittwochOderSamstag(FDate: DateTime): boolean;
         procedure ClearPanel;
         procedure PopulateTabelle;
      protected
         procedure InitializeProperties; override;
      public
         constructor Create(AOwner: TComponent); override;
         procedure LoadData;
      published
         property FontName: string read FFontName write SetFontName;
         property RowCount: Integer read FRowCount;
         property Dataset: TDataset read FDataset write SetDataset;
      end;
</Code>

All published properties are visible in the object inspector and
everything works as expected (setting the dataset property at runtime
works), but the Dataset property doesn't allow to select an existing
dataset. It looks like the attached screenshot shows.

What am I doing wrong?

Thanks Uli



Attachments: Clip3.png
Sun, Dec 11 2016 7:34 AMPermanent Link

Walter Matte

Tactical Business Corporation

I am going to guess here and show my lack of knowledge.

All components that have TDataset are descended from TBindableControl - TBasicPanel is not.

In Runtime that is fine - but in designtime  the TBasicPanel code from TBindableControl to display the Dataset list is not there.


What does your SetDataset method look like?  Does it look like the TBindableControl.SetDataset?  Copy that code - maybe it will work.

Walter
Sun, Dec 11 2016 9:16 AMPermanent Link

Uli Becker

Walter,

> All components that have TDataset are descended from TBindableControl - TBasicPanel is not.
> In Runtime that is fine - but in designtime  the TBasicPanel code from TBindableControl to display the Dataset list is not there.

Yes - that will bei the reason.

> What does your SetDataset method look like?  Does it look like the TBindableControl.SetDataset?  Copy that code - maybe it will work.

I did that, but it didn't changed anything.

Thanks, Walter.

Uli
Mon, Dec 12 2016 7:43 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< I created a component deriving from TBasicPanel. This component reads the content of a TDataset and displays the records in some way. >>

As Walter indicated, you're going to need to descend from TBindableControl for bound controls (TBindableColumnControl for bound controls that bind to a specific column).

Examine the methods in the TBindableControl interface, and then check out the TGrid interface in the WebGrids unit to see how they are overridden and implemented.

I've got to take care of some things this morning, but I will try to work up an example for you.  The TGrid implementation is a little more complicated than it needs to be for what you're trying to do.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Dec 12 2016 9:30 AMPermanent Link

Uli Becker

Tim
<<
I've got to take care of some things this morning, but I will try to work up an example for you.  The TGrid implementation is a little more complicated than it needs to be for what you're trying to do.
>>

Thanks for the clarification and your kind offer. But meanwhile I changed the component in a way that it creates a TDataset at runtime. So I only need the dataset name as a string parameter.

Btw here a sample of the component for mobile phones. You can swipe left and right to change the dates.  The table shows results of the German soccer league. Just a small sample.

https://www.beckersoft-online.de:444/tippliga/project1.html

I love EWB

Uli
Wed, Dec 14 2016 2:59 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< Thanks for the clarification and your kind offer. But meanwhile I changed the component in a way that it creates a TDataset at runtime. So I only need the dataset name as a string parameter.

Btw here a sample of the component for mobile phones. You can swipe left and right to change the dates.  The table shows results of the German soccer league. Just a small sample. >>

Nice. Smile You always create really cool apps with EWB, and it's always appreciated when you share what you've done with everyone else.

Tim Young
Elevate Software
www.elevatesoft.com
Image