Subject Re: TIB_ComboBox in Grid
Author sonic3076
Now I had some time to look into the differences.

the problem is here:

...
if Fields.RowState = rsModified then
begin
if GetLookupText( AColumn, Result ) then
DidGetLookupText := true
else
...

the
function TIB_CustomGrid.GetLookupText( ACol: TIB_Column;
var DispText: string ):

calls

DispText := tmpIntf.GetText;

and the GetText is in this example

...
TIB_CustomComboBox.IBG_GetText: string;
begin
// GetText is supposed to return the untranslated value of the field
...

the comment says it: "untranslated"!!
now the Variable DidGetLookupText is true and the following coding will not execute (especially the TranslateText)

...
// NB. Dont try to re-translate if we had success from GetLookupText
if (ARow >= FixedRows) and (not DidGetLookupText) then
begin
for ii := 0 to ControlCount - 1 do
if Controls[ ii ].GetInterface(IIB_GridWinControl,tmpIntf) and
Assigned(AColumn) and (AColumn = tmpIntf.DisplayColumn) then
Result := tmpIntf.TranslateText( Result );
...


to solve the problem just remove the DidGetLookupText variable consequently

here the whole corrected function:

function TIB_CustomGrid.GetCellDisplayText( ACol, ARow: Longint ): string;
var
ii : integer;
AColumn: TIB_Column;
tmpIntf: IIB_GridWinControl;
begin
if DataLink.Prepared then
with Datalink.BDataset do
begin
AColumn := GridFields[ DataCol[ ACol ]];
if DataLink.Disabled then
Result := ''
else
if ARow < FixedRows then
begin
if ( ARow = FixedRows - 1 ) and
( AColumn <> nil ) then
Result := AColumn.GridDisplayLabel
else
Result := EmptyStr;
end
else
if ACol < FixedCols - FixedDataCols then
Result := ''
else
begin
if BufferRowNum <> DataRow[ ARow ] then
BufferRowNum := DataRow[ ARow ];
Result := '';
if ( RowNum = DataRow[ ARow ] ) and not FHideRowSelection then
begin
if ( Fields.RowState <> rsNone ) and
( AColumn <> nil ) then
if Fields.RowState = rsModified then
begin
if not GetLookupText( AColumn, Result ) then
with AColumn do
if ( gdtShowTextBlob in FDrawCellTextOptions ) and
IsBlob and IsText then
Result := AsString
else
if (( gdtShowNULL in FDrawCellTextOptions ) and IsNull ) then
Result := '(NULL)'
else
Result := DisplayText;
end
else
with AColumn do
if ( gdtShowTextBlob in FDrawCellTextOptions ) and
IsBlob and IsText then
Result := AsString
else
if (( gdtShowNULL in FDrawCellTextOptions ) and IsNull ) then
Result := '(NULL)'
else
Result := DisplayText;
end
else
if ( BufferRowNum = DataRow[ ARow ] ) and
( BuffFields[ DataCol[ ACol ]] <> nil ) then
with BuffFields[ DataCol[ ACol ]] do
begin
if ( gdtShowTextBlob in FDrawCellTextOptions ) and
IsBlob and IsText then
Result := AsString
else
if (( gdtShowNULL in FDrawCellTextOptions ) and IsNull ) then
Result := '(NULL)'
else
Result := DisplayText;
end;
end;
if Prepared then
begin
if (ARow >= FixedRows) then
begin
for ii := 0 to ControlCount - 1 do
if Controls[ ii ].GetInterface(IIB_GridWinControl,tmpIntf) and
Assigned(AColumn) and (AColumn = tmpIntf.DisplayColumn) then
Result := tmpIntf.TranslateText( Result );
end;
if Assigned( OnGetDisplayText ) then
OnGetDisplayText( Self, ACol, ARow, Result );
end;
end;
end;

with this corrected version everything works (at least my app)

I don´t know have tried to speed up this function by adding this "DidGetLookupText"-stuff but he should recheck this function.

regards
Oliver Wurdak

--- In IBObjects@yahoogroups.com, "sonic3076" <o.wurdak@...> wrote:
>
> I tracked down the problem to the procedure
> TIB_CustomGrid.GetCellDisplayText(
> I replaced this function with an older version. (I found an 4.2Ib
> Version on my harddisk) and the behaviour is as it should be.
> The problem is, that I don´t understand the changes between the 2
> versions and I don´t want to downgrade this procedure. Perhaps the
> older version has another error?
>
> Jason, can I send you the 2 versions to check the differences. Or
> should I post it here?
>
> regards
> Oliver
>
> --- In IBObjects@yahoogroups.com, "sonic3076" <o.wurdak@> wrote:
> >
> > Hi
> >
> > I don´t understand the behaviour of a TIB_ComboBox in a Grid.
> > I have a Integer Field with a fixed range of values e.g. 1 2 3 and I
> > want to display "one" "two" "three" in the Grid. So I drop a
> > TIB_ComboBox in the Grid; link it to the field; enter 1 2 3 in the
> > Itemvalues Stringlist and "one" "two" "three" in the Items Stringlist.
> > The style is csDropDownList.
> > When the grid is displayed all values are translated to "one" "two"
> > "three". When I enter the field the drop-down-icon is displayed and I
> > can change the value. Now I jump to the next column. The drop-down
> > icon disappears and the field displays the value (1) instead of "one"
> > This appears only if the record is in edit or insert-mode.
> >
> > Is something wrong in my TIB_ComboBox setup?
> >
> > I use IBO 4.8.7.
> >
> > thanks
> > Oliver
> >
>