andyhill Posted January 7 Share Posted January 7 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 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 7 Share Posted January 7 7 hours ago, andyhill said: ajaxRequest(MainForm.cbLookUpItems, '#39'_Select_'#39', ["r="+record]); Sorry, what is this code? Quote Link to comment Share on other sites More sharing options...
andyhill Posted January 7 Author Share Posted January 7 I want to return a param with the value of the selected text Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 8 Share Posted January 8 8 hours ago, andyhill said: I want to return a param with the value of the selected text Ok, And if the component is created in designtime, then everything works as you want? Quote Link to comment Share on other sites More sharing options...
andyhill Posted January 8 Author Share Posted January 8 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); Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 8 Share Posted January 8 4 minutes ago, andyhill said: IDE fine, runtime creation ISSUE Are you assigning a Name to the dynamically created component? Quote Link to comment Share on other sites More sharing options...
andyhill Posted January 8 Author Share Posted January 8 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 Quote Link to comment Share on other sites More sharing options...
andyhill Posted January 10 Author Share Posted January 10 Sherzod, any ideas ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 10 Share Posted January 10 3 minutes ago, andyhill said: any ideas ? Hello Andy, So that I can reproduce it, can you create a simple test case without extra code please? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.