Jump to content

Combobox Dropdown Not Refreshing


dkeene

Recommended Posts

Hello

I need a strategy or maybe I am doing something wrong. I have a dropdown and user types a few key letters in the edit part of the dropdown, and after a CheckChangeDelay of 4000 (for example), I have a function call within thecombobox.OnChange to return a result set based on the edit box which works well, and then dropdown the combobox for user to select from the results.

Problem is that although I clear the combobox items, they are still in the dropdown list and the dropdown does not reflect the changes that I made.

procedure TfmTableEdit.UniComboBoxChange(Sender: TObject);
var
   MySQL: String;
   
begin
    
   MySQL:=// example "select name from table where name like '%keyword%' limit 7"

   //Clear ComboBox Items.
   TUniDBCombobox(Sender).Items.Clear;
   TUniDBCombobox(Sender).Refresh;
   
   uniMainModule.MPopulateviaSQL(MySQL, TUniComboBox(Sender), 100);  //populates this dbcombobox.items with result set from MySQL.

   //force dropdown to open
   (Sender as TUniDBComboBox).JSInterface.JSCallDefer('expand', [], 200);
   
end;

Any thoughts?
Thanks

Doug

Link to comment
Share on other sites

On 9/7/2020 at 10:28 AM, dkeene said:

Hello

I need a strategy or maybe I am doing something wrong. I have a dropdown and user types a few key letters in the edit part of the dropdown, and after a CheckChangeDelay of 4000 (for example), I have a function call within thecombobox.OnChange to return a result set based on the edit box which works well, and then dropdown the combobox for user to select from the results.

Problem is that although I clear the combobox items, they are still in the dropdown list and the dropdown does not reflect the changes that I made.


procedure TfmTableEdit.UniComboBoxChange(Sender: TObject);
var
   MySQL: String;
   
begin
    
   MySQL:=// example "select name from table where name like '%keyword%' limit 7"

   //Clear ComboBox Items.
   TUniDBCombobox(Sender).Items.Clear;
   TUniDBCombobox(Sender).Refresh;
   
   uniMainModule.MPopulateviaSQL(MySQL, TUniComboBox(Sender), 100);  //populates this dbcombobox.items with result set from MySQL.

   //force dropdown to open
   (Sender as TUniDBComboBox).JSInterface.JSCallDefer('expand', [], 200);
   
end;

Any thoughts?
Thanks

Doug

Hi,

Please set RemoteQuery:=True and use OnRemoteQuery event instead of OnChange event.

You can also check "ComboBox Remote Data" demo. It is for DBLookupCombobox but it is the same idea.

C:\Program Files (x86)\FMSoft\Framework\uniGUI\Demos\Desktop\ComboBox Remote Data

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