-
12 Apr 2012 12:30 AM #1
Old Field.setInputStyleAttribute
Old Field.setInputStyleAttribute
Working on a migration of an old GXT 2.X application project I have a encountered this setting:
NumberField currPag = new NumberField();
...
currPag.setInputStyleAttribute("textAlign","right");
I've tried this kind of "translation" but It doesn't work:
Is there something wrong ? Or is it a bug ?Code:public void onModuleLoad() { IntegerPropertyEditor ipe = new IntegerPropertyEditor(); NumberField<Integer> num = new NumberField<Integer>(ipe); XElement xel = num.getElement(); InputElement iel = num.getCell().getInputElement(xel); // System.out.println(iel); iel.setAttribute("textAlign", "right"); // System.out.println(iel); num.setValue(0); RootPanel.get().add(num); }
-
13 Apr 2012 2:07 AM #2
Not working still in RC2
Not working still in RC2
Already tried this:
Any idea ? Any hint ?Code:public void onModuleLoad() { IntegerPropertyEditor ipe = new IntegerPropertyEditor(); NumberField<Integer> num = new NumberField<Integer>(ipe); XElement xel = num.getElement(); InputElement iel = num.getCell().getInputElement(xel); // System.out.println(iel); iel.getStyle().setProperty("textAlign", "right"); // System.out.println(iel); num.setValue(0); RootPanel.get().add(num); }
-
16 Apr 2012 1:53 PM #3
What you can do here is to set a style name on the field itself, then add a rule in your CSS to select for an input element descendent. That is, call num.addStyleName("foo"), then use a selector like .foo input.
When you set any styles directly on the input element of a cell-based widget, those styles are lost whenever the cell redraws. Because of the architecture of cells, these elements can be redrawn very often (and relatively inexpensively). As a result, any modifications that you made by traversing the DOM tree and modifying elements will likely not be properly long-lived.
I've moved this thread to Discussion because the behaviour you've described is intentional. Please don't hesitate to start other threads in Bugs if you discover any other behaviour you believe to be a bug.
-
20 Apr 2012 2:18 AM #4
Ok, understood what you mean, thanks for that, but how can I right align the content of this new NumberField ?
Can you tell me just some hint ?
Thanks again.


Reply With Quote