Page 1 of 1
Request to expose IsValidDataSource for override
Posted: Wed Aug 25, 2010 3:16 pm
by 16556662
Hello
I am now using BDS2006 C++Builder, with TeeChart 2010 Pro.
Currently, according to example, I need to define a new class derived from TDBChart with IsValidDataSource overridden to have some dataset hidden.
This is very complicated, according to demo, all must be programmed to be created run-time, and many coding work. And also I have headache for cross-unit datasets namespace problems.
Is it possible for TDBChart to expose this IsValidDataSource, so I can do in such a way to have an easy override?
1. Create a new event called OnValidDataSource to pass parameters out for user to further changing -->preferred
or
2. Directly expose the function address of IsValidDataSource for overriding.-->not perferred.
Re: Request to expose IsValidDataSource for override
Posted: Fri Aug 27, 2010 1:49 pm
by yeray
Hi Liang,
I've added your request to the wish list to be studied for inclusion in next releases (TV52015116).
Re: Request to expose IsValidDataSource for override
Posted: Wed Sep 15, 2010 1:14 pm
by 16556662
Hello
I have implemented such exposure of OnValidDataSource event. And it works fine.
Now I can make my software more clean, with only desired DataSet shown to user at run-time.
I would like to contribute my modification on DBChart.pas to you. Please check it:
line 48
Code: Select all
TValidDataSourceEvent=Procedure(Sender:TCustomDBChart; ASeries:TChartSeries; AComponent:TComponent;
var Valid:Boolean) of object;
line 57:
Code: Select all
FOnValidDataSource:TValidDataSourceEvent;
line 91:
Code: Select all
property OnValidDataSource:TValidDataSourceEvent read FOnValidDataSource
write FOnValidDataSource;
line 104:
line 488:
Code: Select all
Function TCustomDBChart.IsValidDataSource(ASeries:TChartSeries; AComponent:TComponent):Boolean;
var
BoolValue:Boolean;
Begin
BoolValue:=inherited IsValidDataSource(ASeries,AComponent);
if not BoolValue then BoolValue:=(AComponent is TDataSet) or (AComponent is TDataSource);
if Assigned(FOnValidDataSource) then
begin
FOnValidDataSource(Self,ASeries,AComponent,BoolValue);
end;
Result:=BoolValue;
end;
Re: Request to expose IsValidDataSource for override
Posted: Fri Sep 17, 2010 9:01 am
by narcis
Hello Liang,
Thank you very much for your contribution. We will analyse it and get back to you as soon as possible.
Re: Request to expose IsValidDataSource for override
Posted: Fri Sep 17, 2010 11:17 am
by narcis
Hi Liang,
I think you can already override IsValidDataSource as in the examples in this
thread. The projects Jørgen posted already derive a class from TDBChart and override IsValidDataSource method. Does this fit your needs?
Re: Request to expose IsValidDataSource for override
Posted: Sun Sep 19, 2010 2:31 am
by 16556662
Hello
I think mine is different, and prefer my way.
My solution is to expose the event of ValildDataSource on the TDBChart level, so I can directly in my source code, catch this event from the TDBChart component, and override the result by user as
Code: Select all
void __fastcall TScriptFrame::ResultDBChartValidDatasource(
TCustomDBChart *Sender, TChartSeries *ASeries, TComponent *AComponent,
bool &Valid)
{
Valid=(AComponent==DataSource->DataSet);
}
//---------------------------------------------------------------------------
So the freedom is at the user side.
Re: Request to expose IsValidDataSource for override
Posted: Wed Sep 22, 2010 8:02 am
by narcis
Hi Liang,
Ok, we implemented this for next maintenance release.