Subject | Re: [IBO] Some features |
---|---|
Author | Geoff Worboys |
Post date | 2001-08-18T09:48:39Z |
Pirtea,
what is happening versus what you think should be happening. Part of
the problem is that I dont use TIB_LookupCombo much myself (I have my
own lookup control), but since I was partly responsible for the
AutoLabel I have been attempting to help get it operating correctly.
So I need some assistance in determining exactly what should be
happening.
LookupCombo.DisplayField - is optional, when defined it specifies the
field used as the display value inside the combo. It is also used on
TIB_Grid to control which column the lookupcombo is used with (by
searching the lookupdataset KeyDescLinks property and matching with
the main dataset descriptive field specified). When the DisplayField
is not specified the currently selected OrderingLink field is used
(from the LookupDataset).
AutoLabel (since IBO_4_2_Ea) attempts to calculate the actual foreign
key field of the main dataset in order to work out whether the field
is mandatory or not (whether it may need to be displayed bold). If
the foreign key field cannot be found (perhaps the datasets are not
prepared or linked properly yet) then the DisplayField is used and
failing that the OrderingField.
However the text used as the label is (currently) calculated using the
following code...
function TIB_CustomCombo.IBG_DisplayColumn: TObject;
var
tmpName: string;
begin
Result := nil;
if Assigned( DataSource ) and Assigned( DataSource.Dataset ) then
with DataSource.Dataset do
if Assigned( KeyDataset ) then
begin
tmpName := DisplayField;
if tmpName = '' then
tmpName := OrderingLink;
Result := KeyDataset.FindField(KeyDescLinks.LinkValues[
tmpName ]);
if not Assigned( Result ) then
Result := KeyDataset.FindField( tmpName );
end;
end;
Which means that it attempts to find the field from the main dataset
which matches the DisplayField (or OrderingLink) via the KeyDescLinks.
This seem to make sense to me, that it tried to retrieve the relevant
column from the main dataset - so that you can define the displaylabel
etc all in the main dataset.
However I am not certain if:
if not Assigned( Result ) then
Result := KeyDataset.FindField( tmpName );
is really correct. Possibly it should read
if not Assigned( Result ) then
Result := FindField( tmpName );
so that it finds the column reference from the lookup dataset itself.
I am happy to be guided on this, but I need more input. Is it all
working as currently designed? If not what is it doing? If so what
needs to be changed? Keep in mind that some things change at runtime
after everything gets prepared. Also keep in mind the differences
that may occur depending on whether DisplayField is defined or not.
Geoff Worboys
Telesis Computing
> Well, the problem is still there but is different now.This has been going on for a while now and I am getting confused over
>
> instead of displaying that table name it now displays
> the key field.
what is happening versus what you think should be happening. Part of
the problem is that I dont use TIB_LookupCombo much myself (I have my
own lookup control), but since I was partly responsible for the
AutoLabel I have been attempting to help get it operating correctly.
So I need some assistance in determining exactly what should be
happening.
LookupCombo.DisplayField - is optional, when defined it specifies the
field used as the display value inside the combo. It is also used on
TIB_Grid to control which column the lookupcombo is used with (by
searching the lookupdataset KeyDescLinks property and matching with
the main dataset descriptive field specified). When the DisplayField
is not specified the currently selected OrderingLink field is used
(from the LookupDataset).
AutoLabel (since IBO_4_2_Ea) attempts to calculate the actual foreign
key field of the main dataset in order to work out whether the field
is mandatory or not (whether it may need to be displayed bold). If
the foreign key field cannot be found (perhaps the datasets are not
prepared or linked properly yet) then the DisplayField is used and
failing that the OrderingField.
However the text used as the label is (currently) calculated using the
following code...
function TIB_CustomCombo.IBG_DisplayColumn: TObject;
var
tmpName: string;
begin
Result := nil;
if Assigned( DataSource ) and Assigned( DataSource.Dataset ) then
with DataSource.Dataset do
if Assigned( KeyDataset ) then
begin
tmpName := DisplayField;
if tmpName = '' then
tmpName := OrderingLink;
Result := KeyDataset.FindField(KeyDescLinks.LinkValues[
tmpName ]);
if not Assigned( Result ) then
Result := KeyDataset.FindField( tmpName );
end;
end;
Which means that it attempts to find the field from the main dataset
which matches the DisplayField (or OrderingLink) via the KeyDescLinks.
This seem to make sense to me, that it tried to retrieve the relevant
column from the main dataset - so that you can define the displaylabel
etc all in the main dataset.
However I am not certain if:
if not Assigned( Result ) then
Result := KeyDataset.FindField( tmpName );
is really correct. Possibly it should read
if not Assigned( Result ) then
Result := FindField( tmpName );
so that it finds the column reference from the lookup dataset itself.
I am happy to be guided on this, but I need more input. Is it all
working as currently designed? If not what is it doing? If so what
needs to be changed? Keep in mind that some things change at runtime
after everything gets prepared. Also keep in mind the differences
that may occur depending on whether DisplayField is defined or not.
Geoff Worboys
Telesis Computing