MarcoZC Posted August 20, 2020 Share Posted August 20, 2020 In the source I write this command to assing a clientevent.extevent. If run the application it does not work bud if I assign this in dessign time work ok. z := 'afterrender=function afterrender(sender, eOpts) { sender.allowBlank = false; }'; TUniDBDateTimePicker(edit).ClientEvents.ExtEvents.Add( z ); I need make another job to meke work this code?? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted August 20, 2020 Share Posted August 20, 2020 7 minutes ago, MarcoZC said: In the source I write this command to assing a clientevent.extevent. If run the application it does not work bud if I assign this in dessign time work ok. Hello, http://forums.unigui.com/index.php?/topic/11352-clienteventsextevents-not-fire-if-added-in-runtime-mode-if-control-is-also-created-at-runtime/&do=findComment&comment=60231 Quote Link to comment Share on other sites More sharing options...
MarcoZC Posted August 20, 2020 Author Share Posted August 20, 2020 35 minutes ago, Sherzod said: Hello, http://forums.unigui.com/index.php?/topic/11352-clienteventsextevents-not-fire-if-added-in-runtime-mode-if-control-is-also-created-at-runtime/&do=findComment&comment=60231 if we create the component at runtime this may work (it seems that the key is to assign a name to the component). But as I said, I create the components at design time, so that they already have a name, and then at runtime I want to assign the afterrender depending on the Datasource field having the required property set to true. This is the code I use, but it doesn't work. procedure TUniManPol.GetRequiredField; var x: integer; o: TComponent; f: TField; c, z : string; begin z := 'afterrender=function afterrender(sender, eOpts) { sender.allowBlank=false; }'; for x := 0 to ComponentCount-1 do begin o := Components[x]; c := ''; f := nil; t := ''; // Tipo de dbedit if o is TUniDBEdit then begin t := 'TUniDBEdit'; c := TUniDBEdit(o).DataField; f := TUniDBEdit(o).Datasource.Dataset.fieldbyName(c); if f.Required then begin TUniDBEdit(o).ClientEvents.ExtEvents.Add( z ); TUniDBEdit(o).ClientEvents.Enabled := True; end; end; if o is TUniDBDateTimePicker then begin t := 'TUniDBDateTimePicker'; c := TUniDBDateTimePicker(o).DataField; f := TUniDBDateTimePicker(o).Datasource.dataset.fieldbyName(c); if f.Required then begin TUniDBDateTimePicker(o).ClientEvents.ExtEvents.Add( z ); TUniDBDateTimePicker(o).ClientEvents.Enabled := True; end; end; if o is TUniDBLookupComboBox then begin t := 'TUniDBLookupComboBox'; c := TUniDBLookupComboBox(o).DataField; f := TUniDBLookupComboBox(o).Datasource.dataset.fieldbyName(c); if f.Required then begin TUniDBLookupComboBox(o).ClientEvents.ExtEvents.Add( z ); TUniDBLookupComboBox(o).ClientEvents.Enabled := True; end; end; end; end; 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.