Jump to content

DBLookupCombobox, show first from 1 row, refresh problems


Kast2k

Recommended Posts

Hello!

There are AdoQuery (aq), Datasource(ds) and DbLookupcombobox (dbc) placed on frame. Also i have a variable integer (varInt=3) for locating data in dbc.

aq have 1 parameter and returns 2 fields and configured as ds.Dataset=aq

select
idStatus,
StatusName
from tblStatuses
where
	idRelational = :idRelational

dbc is configured like

Listsource=ds

ListField=StatusName

KeyField=idStatus

 

After setting the parameter (idRelational=3)

aq.Parameters.ParamByName('idRelational').Value=varInt

the dbc is refreshed like:

procedure TUniMainModule.RefreshDBComboBox(dbc: TUniDBLookupComboBox);
begin
  dbc.BeginUpdate;
  try
    try
      dbc.ListSource.DataSet.Close;
      dbc.ListSource.DataSet.Open;
    except
      on E: Exception do
        begin
          PostToLog('RefreshDBComboBox error='+e.Message);
        end;
      on E: EOleException do
        begin
          PostToLog('RefreshDBComboBox error='+e.Message);
        end;
    end;
  finally
    dbc.EndUpdate;
  end;
end;

After that i'm trying to locate data by this code:

function TUniMainModule.LocateData(cb: TUniDBLookupComboBox;
  const AValue: Variant; const AFieldName: string): Boolean;
var
  b:Boolean;
begin
  b:=False;
  try
    if not VarIsNull(AValue) then
      begin
        if (VarIsNumeric(AValue) and (AValue<=0)) or (VarIsStr(AValue) and (AValue='')) then
          begin
            cb.KeyValue:=null;
            Exit;
          end;
        try
          b:=cb.ListSource.DataSet.Locate(AFieldName,AValue,[loCaseInsensitive]);
          if b then
            cb.KeyValue:=cb.ListSource.DataSet.FieldByName(cb.KeyField).Value
          else
            cb.KeyValue:=null;
        except
          on E: Exception do
            begin
              UniSession.Log(Format('Error LocateData( %s, %s )= %s ',[AFieldName, VarToStr(AValue), e.Message]));
            end;
          on E: EOleException do
            begin
              UniSession.Log(Format('Error LocateData( %s, %s )= %s ',[AFieldName, VarToStr(AValue), e.Message]));
            end;
        end;
      end
    else
      cb.KeyValue:=null;
  finally
    Result:=b;
  end;
end;
                                                 
                                                 
procedure TMyFrame.FindAndShowRowData;
begin
	if UniMainModule.LocateData(dbc,varInt,'idStatus') then
      begin
      end                                                 
end;                                                 

If i'm opening frame for first time then i can see that LocateData works OK and the only 1 row is showed by component.

But if i executing this code (set parameter (3->4), refreshDBCombobox, locatedata) on opened frame again then component dbc shows nothing, but cb.ListSource.DataSet.Locate returns TRUE, needed row exists in list and i can select it manually.

What am i doing wrong or is it DBLookupCombobox bug?

Unigui 1.90.0.1528.

Link to comment
Share on other sites

Also,

AllFeaturesDemo ->Grids ->Filter 2

If you click on Country column filter then You can scroll list only by mouse wheel or clicking on arrows on vertical scrollbar. You can't move scroll with pressed left mouse button.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...