Jump to content

TUniComboBox Created At Runtime: Read CloseUp Text Issue


andyhill

Recommended Posts

I am creating cbLookUpItems (as a grid editor) complete with data (showing when dropdown) and all events are firing.

cbLookUpItems.OnChange:= cbLookUpItemsChange; (cbLookUpItems.Text always shows '' in events)
cbLookUpItems.OnSelect:= cbLookUpItemsSelect; (cbLookUpItems.ItemIndex always 0)

So added my own event

  MyScript:= 'select=function select(combo, record, eOpts)'#13#10 +
             '{'#13#10 +
             '  ajaxRequest(MainForm.cbLookUpItems, '#39'_Select_'#39', ["r="+record]); '#13#10 + PLEASE SHOW HOW TO SET CHOSEN DATA IN PARAM
             '} ';
  cbLookUpItems.ClientEvents.ExtEvents.Add(MyScript);

SAME
cbLookUpItems.Text always shows '' in events
cbLookUpItems.ItemIndex always 0

Even added defer between change and select.

Please advise - thanks

Link to comment
Share on other sites

IDE fine, runtime creation ISSUE (even though events all fire) so need to pass TEXT SELECTION back in Params below

MyScript:= 'select=function select(combo, record, eOpts)'#13#10 +
             '{'#13#10 +
             '  ajaxRequest(MainForm.cbLookUpItems, '#39'_Select_'#39', ["r="+record]); '#13#10 + PLEASE SHOW HOW TO SET CHOSEN DATA IN PARAM
             '} ';
cbLookUpItems.ClientEvents.ExtEvents.Add(MyScript);

Link to comment
Share on other sites

YES, I only fell for that once.

 

    cbLookUpItems: TUniComboBox; 
 

...


  //////////////////////////////////////////////////////////////////////////////
  cbLookUpItems:= TUniComboBox.Create(HiddenPanel); 
  cbLookUpItems.Name:= 'cbLookUpItems';
  cbLookUpItems.OnAjaxEvent:= cbLookUpItemsAjaxEvent;
  //
  cbLookUpItems.BeginUpdate;
  cbLookUpItems.Items.Clear;
  cbLookUpItems.Items.Add('');
  if UniMainModule.MyQuery1.Active then UniMainModule.MyQuery1.Close;
  UniMainModule.MyQuery1.SQL.Clear;
  UniMainModule.MyQuery1.Params.Clear;
  UniMainModule.MyQuery1.SQL.Add('SELECT Description '+
  'FROM Items '+
  'WHERE HideFromView <> TRUE '+
  'ORDER BY Description ;');
  UniMainModule.MyQuery1.Open;
  while not UniMainModule.MyQuery1.Eof do begin
    cbLookUpItems.Items.Add(Trim(UniMainModule.MyQuery1.FieldByName('Description').AsString));
    UniMainModule.MyQuery1.Next;
  end;
  UniMainModule.MyQuery1.Close; // 209 items added
  cbLookUpItems.EndUpdate;
  //
  cbLookUpItems.OnCloseUp:=     cbLookUpItemsCloseUp;
  cbLookUpItems.OnChange:=      cbLookUpItemsChange;
  cbLookUpItems.OnChangeValue:= cbLookUpItemsChangeValue;
  //cbLookUpItems.OnSelect:=      cbLookUpItemsSelect;
  //
  cbLookUpItems.ClientEvents.ExtEvents.Clear;
  MyScript:= 'beforeselect=function beforeselect(combo, record, index, eOpts)'#13#10 +
             '{'#13#10 +
             '  ajaxRequest(MainForm.cbLookUpItems, '#39'_beforeSelect_'#39', []); '#13#10 +
             '} ';
  cbLookUpItems.ClientEvents.ExtEvents.Add(MyScript);
  //
  MyScript:= 'select=function select(combo, record, eOpts)'#13#10 +
             '{'#13#10 +
             '  ajaxRequest(MainForm.cbLookUpItems, '#39'_Select_'#39', ["r="+record]); '#13#10 +
             '} ';
  cbLookUpItems.ClientEvents.ExtEvents.Add(MyScript);

 

ALL EVENTS SHOW

TEXT ''

ITEMINDEX 0

 

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