Jump to content

Recommended Posts

Posted

I have a UniDBLookupComboBox on a form that has the listsource property bound to a datasource that is bound to a TFDQuery.

In this form I have a button that opens another form where I insert into the database in the same table to which my UniDBLookupComboBox pulls the items.

What happens is that right after I register a new record in the table, and trying to use KeyValue with the new item is not setting the value in UniDBLookupComboBox.

Note: clicking on the combo already appears the new item in the list.

Does anyone know the best way to do this?

My code:

procedure TFormOrdemServico.imgPesquisaCombustivelClick(Sender: TObject);
var
  FormCadastroCombustivel : TFormCadastroCombustivel;
begin
  if UniApplication.FindComponent('FormCadastroCombustivel') <> nil then
    Exit;
  ShowMask('Aguarde...');
  UniSession.Synchronize();
  FormCadastroCombustivel := TFormCadastroCombustivel.Create(UniApplication);
  HideMask;
  FormCadastroCombustivel.ShowModal();
  cbCombustivel.ListSource.DataSet.Refresh;
  if FormCadastroCombustivel.ModalResult = mrOk then begin
    cbCombustivel.KeyValue := FormCadastroCombustivel.qryTemplateCOMBICOD.AsInteger;
  end;
  FreeAndNil(FormCadastroCombustivel);
end;

 

Posted
5 hours ago, Multistore said:

I have a UniDBLookupComboBox on a form that has the listsource property bound to a datasource that is bound to a TFDQuery.

In this form I have a button that opens another form where I insert into the database in the same table to which my UniDBLookupComboBox pulls the items.

What happens is that right after I register a new record in the table, and trying to use KeyValue with the new item is not setting the value in UniDBLookupComboBox.

Note: clicking on the combo already appears the new item in the list.

Does anyone know the best way to do this?

Hello,

Can you please specify, which edtion and build of UniGUI are you using?

Posted

I noticed that this problem only occurs when saving a new database record, if KeyValue does not save it works normally.

When I save a new item in the database it does not update UniDBLookupComboBox text when using KeyValue.

I tried using the UpdateText method of UniDBLookupComboBox, when I did that the text updated with the description of the new record, but if I don't save any records and trying to use KeyValue doesn't update the combo text.

Any idea?

  • Like 1
  • 1 month later...
Posted

Same problem here.. I'm using trial version 1.90 (latest disponible).

UniDBLookupComboBoxBank.ListSource := FBankController.ReturnDataSource;

// Other settings are on .dfm, and it show properly all itens from the database

UniDBLookupComboBoxBank.KeyValue := FBankEntity.ID;

// It makes no change at all. The KeyField on the component is correct, the record exists, the ID is correct...

I need this to complete my tests on the framework to consider buying it.

Posted
6 hours ago, cardoso said:

Same problem here.. I'm using trial version 1.90 (latest disponible).


UniDBLookupComboBoxBank.ListSource := FBankController.ReturnDataSource;

// Other settings are on .dfm, and it show properly all itens from the database

UniDBLookupComboBoxBank.KeyValue := FBankEntity.ID;

// It makes no change at all. The KeyField on the component is correct, the record exists, the ID is correct...

I need this to complete my tests on the framework to consider buying it.

I found what i was doing wrong...

The "KeyValue" field should be set when the "TUniDBLookupComboBox" is fully loaded. I changed the event "OnShow" for "OnReady" and it worked.

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...