Wilton Ergon Posted April 24, 2021 Share Posted April 24, 2021 I create tunimdatepicket controls dynamically, but I can't set the aftercreate event to change the button's title. the code below works when the component is already on the screen. but it doesn't work when it's created dynamically. var cDateTimePicker:TUniMDatePicker cDateTimePicker := TUniMDatePicker.Create(self); cDateTimePicker.ClientEvents.UniEvents.Values['afterCreate'] := 'function afterCreate(sender) '+ '{ '+ ' var me=sender.getPicker(); '+ ' if (me && !Ext.isWindows) { '+ ' me.getDoneButton().setText("OK"); '+ ' me.getCancelButton().setText("X") '+ ' } '+ '}'; Quote Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted April 24, 2021 Share Posted April 24, 2021 3 minutes ago, wilton_rad said: I create tunimdatepicket controls dynamically, but I can't set the aftercreate event to change the button's title. the code below works when the component is already on the screen. but it doesn't work when it's created dynamically. var cDateTimePicker:TUniMDatePicker cDateTimePicker := TUniMDatePicker.Create(self); cDateTimePicker.ClientEvents.UniEvents.Values['afterCreate'] := 'function afterCreate(sender) '+ '{ '+ ' var me=sender.getPicker(); '+ ' if (me && !Ext.isWindows) { '+ ' me.getDoneButton().setText("OK"); '+ ' me.getCancelButton().setText("X") '+ ' } '+ '}'; Hi Can you please create a test case? Quote Link to comment Share on other sites More sharing options...
Wilton Ergon Posted April 26, 2021 Author Share Posted April 26, 2021 the test had been done on a previous version of the unigui, the current 1547, it is working. thanks. Quote Link to comment Share on other sites More sharing options...
GerhardV Posted May 14, 2021 Share Posted May 14, 2021 I still have the issue, just with a TUniLabel. ClientEvents.UniEvents.Values['beforeInit'] := 'function beforeInit(sender, config){config.cls = "app-h3 app-color-primary";}'; Does not work with 1549 build. Have to do it like this because the "LayoutConfig.Cls" property is protected and not public, yet is is published. Quote Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted May 14, 2021 Share Posted May 14, 2021 25 minutes ago, GerhardV said: I still have the issue, just with a TUniLabel. ClientEvents.UniEvents.Values['beforeInit'] := 'function beforeInit(sender, config){config.cls = "app-h3 app-color-primary";}'; Does not work with 1549 build. Have to do it like this because the "LayoutConfig.Cls" property is protected and not public, yet is is published. Can you check below code? with unilabel1, jsinterface do jsconfig('cls', ['app-h3- app-color-primary']); Quote Link to comment Share on other sites More sharing options...
GerhardV Posted May 14, 2021 Share Posted May 14, 2021 Thanks Hayri, yes I already done that and it works just fine, but I would really want the LayoutConfig.Cls property to be public. To me published implies public. I would also like to know why the setting of the UniEvents value isn't working, that should be fine because the TUniLabel is created on the "server side" at the point in time, unless I am missing something. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 14, 2021 Share Posted May 14, 2021 1 hour ago, GerhardV said: I still have the issue, just with a TUniLabel. ClientEvents.UniEvents.Values['beforeInit'] := 'function beforeInit(sender, config){config.cls = "app-h3 app-color-primary";}'; Does not work with 1549 build. Hello, Are you creating the component dynamically at runtime? Quote Link to comment Share on other sites More sharing options...
GerhardV Posted May 15, 2021 Share Posted May 15, 2021 Dynamically on the UniFormCreate method: with TUniLabel.Create(Self) do begin Caption := 'Blah'; Align:= alTop; CreateOrder := index+1; LayoutConfig.Margin := '10 10 5 10'; //This doesn't work //ClientEvents.UniEvents.Values['beforeInit'] := 'function beforeInit(sender, config){config.cls = "app-h3 app-color-primary";}'; //This work JSInterface.JSConfig('cls',['app-h3 app-font-600 app-color-secondary']); Parent := pnlClientArea; end; This happens in a loop which creates several labels. The parent container is a panel with the layout set to vbox. What is your definition of runtime or dynamically? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 15, 2021 Share Posted May 15, 2021 1 hour ago, GerhardV said: with TUniLabel.Create(Self) do begin Caption := 'Blah'; Align:= alTop; CreateOrder := index+1; LayoutConfig.Margin := '10 10 5 10'; //This doesn't work //ClientEvents.UniEvents.Values['beforeInit'] := 'function beforeInit(sender, config){config.cls = "app-h3 app-color-primary";}'; //This work JSInterface.JSConfig('cls',['app-h3 app-font-600 app-color-secondary']); Parent := pnlClientArea; end; Okay, Assign a name to the component. with TUniLabel.Create(Self) do begin Caption := 'Blah'; Align:= alTop; Name := ... Quote Link to comment Share on other sites More sharing options...
GerhardV Posted May 15, 2021 Share Posted May 15, 2021 Of course yes - thanks! Which method will result in less network traffic? 1. ClientEvents.UniEvents.Values['beforeInit'] := 'function beforeInit(sender, config){config.cls = "app-h3 app-color-primary";}'; or 2. JSInterface.JSConfig('cls',['app-h3 app-font-600 app-color-secondary']); Since we don't have the source code of UniGuiClasses, I assume that (1.) is happening on the server side while the "client JavaScript" is being constructed, whereas with (2.) the call is only happening afterwards as the JavaScript has already been constructed? Maybe @Farshad Mohajeri can shed some light on when what is happening and which is better practice? I still would like to know why LayoutConfig.Cls is not public. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 15, 2021 Share Posted May 15, 2021 20 minutes ago, GerhardV said: Which method will result in less network traffic? 20 minutes ago, GerhardV said: 2. JSInterface.JSConfig('cls',['app-h3 app-font-600 app-color-secondary']); Quote Link to comment Share on other sites More sharing options...
GerhardV Posted May 15, 2021 Share Posted May 15, 2021 You are probably referring to the payload, I was more wondering about round trips between the browser and server. In the case of "JSInterface.JSConfig" I was wondering if the application JS get constructed and send to the browser and only after that the "JSInterface.JSConfig('cls',['app-h3 app-font-600 app-color-secondary']); call is send to the browser. I did a small test and it seems that both gets build on initial construction of the application JS. O13 = new Ext.form.Label({ id: "O13_id", beforeinit: function (sender, config) { config.cls = "app-h3 app-color-primary"; }, text: "ClientEvents.UniEvents", x: 32, y: 24 }); O13.nm = "O13"; _cdo_("UniLabel1", O13, null, MainForm); O17 = new Ext.form.Label({ id: "O17_id", cls: "app-h3 app-font-600 app-color-secondary", text: "JSInterface.JSConfig", x: 368, y: 24 }); O17.nm = "O17"; _cdo_("UniLabel2", O17, null, MainForm); So I will then expect if LayoutConfig.Cls is public it will also result in: O17 = new Ext.form.Label({ id: "O17_id", cls: "app-h3 app-font-600 app-color-secondary", text: "JSInterface.JSConfig", x: 368, y: 24 }); Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 15, 2021 Share Posted May 15, 2021 56 minutes ago, Sherzod said: JSInterface.JSConfig('cls',['app-h3 app-font-600 app-color-secondary']); Use this for now. 11 minutes ago, GerhardV said: if LayoutConfig.Cls is public I will open a request. Quote Link to comment Share on other sites More sharing options...
GerhardV Posted May 15, 2021 Share Posted May 15, 2021 Thank you Sherzod, appreciate it. Please check all the LayoutConfig properties, I think BodyCls is also not public, there may be more. Regards, Gerhard Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 15, 2021 Share Posted May 15, 2021 OK. I opened a request. 1 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.