Wicket Posted January 18, 2018 Share Posted January 18, 2018 Hi Guys, I am having an issue with text alignment of TunimDBNumberEdit, its seems no matter the property I change it always appears right aligned, even when alignment is set to left. I am using client side alignment and vbox on the form, and the fieldset contains the controls. Below are two images, one of TunimDBEdit (which is aligned as I would expect) then TunimDBNumberEdit which is not. Image Link to explain, https://www.dropbox.com/s/ax4ewhm93b51oyy/text_alignment_issue.png?dl=0 Thanks *Edit* I am just trying to achieve a a list of fields which all work and align fine, apart from the TunimDBNumberEdit control. Am I missing something? Link to comment Share on other sites More sharing options...
Sherzod Posted January 18, 2018 Share Posted January 18, 2018 Hi, This approach can help you: http://forums.unigui.com/index.php?/topic/5842-tunidbedit-alignment-property/&do=findComment&comment=29979 Best regards, Link to comment Share on other sites More sharing options...
Wicket Posted January 18, 2018 Author Share Posted January 18, 2018 Thanks, i will take a look once I am back at my computer. I did search before posting this, not sure how I missed that post! Sent from my Pixel using Tapatalk Link to comment Share on other sites More sharing options...
Sherzod Posted January 18, 2018 Share Posted January 18, 2018 Sorry, seems you meant Label align Ok, try this solution: function beforeInit(sender, config) { config.style = {'text-align':'left'}; } Link to comment Share on other sites More sharing options...
Wicket Posted January 18, 2018 Author Share Posted January 18, 2018 Thanks - That did the trick Link to comment Share on other sites More sharing options...
Wicket Posted June 13, 2018 Author Share Posted June 13, 2018 Rather than opening a new thread I will ask here as the problem is related. The above code works perfectly for controls created at design time. However, I now need to create controls at runtime - and the alignment for the TUnimDbNumberEdit label is now incorrect, as per the image. What do I need to do to make the label alignment as other controls, as per the image. FYI - I am using touch 4.2, and build 1425 - I am hoping to upgrade to latest build ASAP, but for now I am stuck on this build, as I am just finishing the project. https://www.dropbox.com/s/rojhmz3cwny5l80/label_alignment.png?dl=0 Thanks, Dan. Link to comment Share on other sites More sharing options...
Sherzod Posted June 14, 2018 Share Posted June 14, 2018 Hi, How do you create in runtime?Can you give a sample code, and do you also assign a name to the component? Link to comment Share on other sites More sharing options...
Wicket Posted June 14, 2018 Author Share Posted June 14, 2018 I iterate a dataset to create any items, this is the reason why I create at runtime, as I do not know how many items are needed at design time. I do not give the component a name Here is the code I use, which creates all items as I want, just the label alignment can not be changed of TUnimDbNumberEdit. number := TUnimDbNumberEdit.Create(FrmMain); //alignment number.ClientEvents.UniEvents.Values['beforeInit']:= 'function beforeInit(sender, config) {config.style = {''text-align'':''left''}'; number.Parent := fieldSet; number.DataSource := dsList; number.DataField := _FieldName; number.FieldLabel := _Caption; number.FieldLabelWidth := 40; I will try giving the component a name and report back. Link to comment Share on other sites More sharing options...
Sherzod Posted June 14, 2018 Share Posted June 14, 2018 I do not give the component a name Assign a name to components Link to comment Share on other sites More sharing options...
Wicket Posted June 14, 2018 Author Share Posted June 14, 2018 OK, Once adding a name to the component I get 'Ajax Error' 'Unexpected Token' - which I guess means my JS is incorrect? number.ClientEvents.UniEvents.Values['beforeInit']:= 'function beforeInit(sender, config) {config.style = {''text-align'':''left''}'; Can you confirm this is correct - perhaps the it does not like the double quoted string for {''text-align'':''left''} ? Link to comment Share on other sites More sharing options...
Sherzod Posted June 14, 2018 Share Posted June 14, 2018 you have missed } at the end Link to comment Share on other sites More sharing options...
Wicket Posted June 14, 2018 Author Share Posted June 14, 2018 DOH! Embarrasing. Thanks , I've been looking at that code for the last 20 mins and just couldn't see the missing } That's sorted my issue. Thanks again Sent from my Pixel using Tapatalk Link to comment Share on other sites More sharing options...
Recommended Posts