PDA

View Full Version : Text Field - Aligning text with right alignment for a number type content



thursday
3 Nov 2011, 6:20 PM
I would like to do the same thing in GXT as the per the ExtJS instructions

http://www.sencha.com/forum/showthread.php?135554-how-to-align-text-on-a-textfield-to-the-right

TextField<String> field = new TextField<String>();

field.setStyleAttribute("text-align", "right");

But it does not work. Please help.

sven
4 Nov 2011, 2:44 AM
Take a look at the output with Firebug. You will see that you assign the text align to the wrong element. You need to assign it to the input element. You are assigning it to the wrapping div.

thursday
21 Apr 2012, 4:43 AM
Sven,

Thanks for the reply.

I am able to make the field right aligned by using this code.


field.el().getChild(0).setStyleAttribute("text-align", "right");

I am wondering if this is the right way to access the input element. I am setting each field with an unique ID. Can I access the input element using the ID of the input element with "ID-input"?. What piece of code I should use?

Thanks

Elwood_76
2 Feb 2013, 12:39 PM
try with this .setInputStyleAttribute("text-align", "right");