PDA

View Full Version : Chang Background color of a textarea is not possible



miwe76
26 Jul 2010, 5:22 AM
Hello with GXT 2.0 i changed the background color of a textarea with following example:
textarea.setStyleAttribute("background-color", "#B0C4DE");

with GXT 2.2 the background color is not changed anymore....
in need a method like this:
textarea.setInputStyleAttribute("background-color", "#B0C4DE");
But this isnt in the API the background color only white.

Thanks for help

Michael

sven
26 Jul 2010, 5:24 AM
This is not a bug. Please read the bugforum guidelines.

I suggest you inspect the element with firebug and you will figure it out quite fast

miwe76
26 Jul 2010, 5:31 AM
Yes i use firebug.
There is a css class on the textarea with the name: x-form-field AND x-form-textarea
ic created my own css class:
.textarea-readonly{
background: #B0C4DE;
color: #000000;
cursor: default !important;
}

i add it with textarea.addInputStyleName("input-readonly");

but its still white
When its not a bug, what is the right method name to change the background?

Micha

sven
26 Jul 2010, 5:33 AM
input-readonly != textarea-readonly

Also firebug will tell you exactly why it is not working.

miwe76
26 Jul 2010, 5:46 AM
sorry,
it is
textarea.addInputStyleName("textarea-readonly");

Yes firebug tells me that the other css classes say this:
.x-form-text, textarea.x-form-field {
background-color:#FFFFFF;
background-image:url("../images/default/form/text-bg.gif");
border-color:#B5B8C8;
}

so i tried out

textarea.removeInputStyleName("x-form-text");
textarea.removeInputStyleName("textarea.x-form-field");

but this changes nothing....
What method of the textarea removes default css classes or changes my background color?

sven
26 Jul 2010, 7:17 AM
So there is probably another rule that is higher and overrides yours.

You can either add the !important flag to your css, or change the rule to eb higher than the other. All this is basic css.