View Full Version : [gxt 2.3.0] Issues with hiding triggers of TriggerFields

Nico P
19 Apr 2012, 1:22 AM
My issues are related to this one: http://www.sencha.com/forum/showthread.php?99164-FNR-ComboBox-CSS-bug-GXT-2.1.3

I have overriden the class combobox to toggle the visibility of the trigger.

1st: TriggerField#setHideTrigger() sets the visibility flag but does not call any resize or repaint methods for the input field. That might have been fixed already in the trunk. I trigger the resizing manually in a deffered command (otherwise width calculation is wrongly). Is there a better way to resize the input field correctly?

2nd: After the trigger was hidden and set back to visible the trigger is positioned wrongly. The style attribute display: block is added by El#setDisplayed(boolean) after trigger.setVisible(true) was called. My workaround removes the style attribute if the trigger is set to visible again.

Here is my code:

private static class ComboBox_ extends ComboBox<StringBaseModel> {

/** {@inheritDoc} */
protected void onRender(Element parent, int index) {
super.onRender(parent, index);

/* performance issue: we are not interested in mouse move events -> disable them */

private void setTriggerVisible(boolean visible) {
if (trigger == null || trigger.isVisible() != visible) {
/* if the combobox was not rendered yet simply set the flag, onRender does the rest */
setHideTrigger(visible == false);

/* component is already rendered */
if (trigger != null) {
if (visible) {
/* fixes wrong position of trigger icon */
trigger.setStyleAttribute("display", null);

/* call resizing in a deferred command to avoid wrong size calculation */
Scheduler.get().scheduleDeferred(new Command() {

/** {@inheritDoc} */
public void execute() {
onResize(getWidth(), getHeight());

Thanks & Greetings, Nico.