Jump to content


Photo

TunimDBNumberEdit text (field) alignment

text alignment TunimDBNumberEdit

  • Please log in to reply
11 replies to this topic

#1 dan602

dan602

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 92 posts

Posted 18 January 2018 - 01:18 PM

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


  • 0

#2 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4968 posts

Posted 18 January 2018 - 04:45 PM

Hi,

 

This approach can help you:

http://forums.unigui...rty/#entry29979

 

Best regards,


  • 0

#3 dan602

dan602

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 92 posts

Posted 18 January 2018 - 04:50 PM

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
  • 0

#4 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4968 posts

Posted 18 January 2018 - 06:01 PM

Sorry, seems you meant Label align

 

Ok, try this solution:

function beforeInit(sender, config)
{
    config.style = {'text-align':'left'};
}

  • 0

#5 dan602

dan602

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 92 posts

Posted 18 January 2018 - 08:54 PM

Thanks - That did the trick


  • 0

#6 dan602

dan602

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 92 posts

Posted 13 June 2018 - 08:03 PM

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....gnment.png?dl=0

 

Thanks, Dan.


  • 0

#7 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4968 posts

Posted 14 June 2018 - 05:41 PM

Hi,

 

How do you create in runtime?
Can you give a sample code, and do you also assign a name to the component?


  • 0

#8 dan602

dan602

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 92 posts

Posted 14 June 2018 - 05:52 PM

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.


  • 0

#9 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4968 posts

Posted 14 June 2018 - 05:58 PM

I do not give the component a name

 

Assign a name to components


  • 0

#10 dan602

dan602

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 92 posts

Posted 14 June 2018 - 06:00 PM

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''} ?


  • 0

#11 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 4968 posts

Posted 14 June 2018 - 06:14 PM

you have missed } at the end


  • 0

#12 dan602

dan602

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 92 posts

Posted 14 June 2018 - 06:22 PM

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
  • 0





Also tagged with one or more of these keywords: text alignment, TunimDBNumberEdit

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users