PDA

View Full Version : Feature Request: add x-form-item-readonly class on setReadOnly



Arno.Nyhm
21 Aug 2009, 6:15 AM
sometimes you need a different style if a component is readonly.
because of ie not reander all css selectors then you have to add manualy every time a style.

so the best is: if you set a item to readonly thenn add a additional readony class to the wrapper:


class="x-form-item x-form-item-readonly"



PS: where its useful? http://extjs.com/forum/showthread.php?t=78266

Branco
21 Aug 2009, 9:00 AM
I have exactly the same problem!

My initial approach was to extend TextField and override the setReadOnly method.


@Override
public void setReadOnly(boolean readOnly) {
super.setReadOnly(readOnly);

if (readOnly){
this.setStyleAttribute(AppConstants.CSS_BACKGROUND_COLOR, AppConstants.COLOR_READ_ONLY);
}
else{
this.setStyleAttribute(AppConstants.CSS_BACKGROUND_COLOR, AppConstants.COLOR_DEFAULT);
}
}This works fine for TextField, but sucks for ComboBox and DateField, as they use some sort of white image that get's repeated, to "emulate" the input.

So if the developpers don't go with Arno.Nyhm's suggestion, they migth as well make the input attribute (of type El) of the TriggerField class accessible via getter, so that we could use setStyleAttribute on it.

It's the input parameter, that is protected, that is painting a white box over the BACKGROUND IMAGE!

EdwinK
25 Aug 2009, 3:46 AM
Until this feature is implemented, you can use the following work-around (works also for DateFields and ComboBoxes):


public static void setReadOnly(Field field){
field.setReadOnly(true);
field.addStyleName("read-only");
field.addInputStyleName("read-only");
}

public static void setReadWrite(Field field){
field.setReadOnly(false);
field.removeStyleName("read-only");
field.removeInputStyleName("read-only");
}


with css:

.read-only{
background-color:#DFE8F6 !important;
background-image: none !important;
}

sven
25 Aug 2009, 4:07 AM
Added to SVN