0

I'm using the DateField in Gxt 3.1.1, please help me how can I customize/remove the hover effect when the mouse hovered on 'Today' button as in the example. I've tried to write a wrapper of DatePickerCustom as below to access todayBtn behavior,

public class DatePickerCustom extends DatePicker {
    public DatePickerCustom() {
        super();
    }
    public TextButton getTodayButton() {
        return this.todayBtn;
    }
}

which is used by DateField internally, and wrote a wrapper for DateField as below to access DatePickerCustom as below to override the existing behavior of getDatePicker() in DateField

public class DateFieldCustom extends DateField {
    private DatePickerCustom myPicker;
    public DateFieldCustom(){
        super();
        myPicker = new DatePickerCustom();
    }
    @Override
    public DatePickerCustom getDatePicker(){
        return myPicker;
    }
    public init(){
        myPicker.getTodayButton().removeToolTip(); //line 1
        myPicker.getTodayButton().setToolTipConfig(null) //line 2
    }
}

Surprisingly the code at //line 1 or 2 has no effect to remove hover effect on 'Today' hover of DateField.

Please help.

1 Answers1

0

TodayButton defined with protected access modifier to access and control the behavior of Today button you have have to extend the class and handle it.

  1. Subclass the Datepicker
  2. Expose the Today button through public method.
  3. Now you have full access to today button. So you can manage as you want.
  4. Set the setToolTipConfig to null to hide the tooltip. Eg: picker.getTodayButton().removeToolTip(); or picker.getTodayButton().setToolTipConfig(null)

public class DatePickerCustom extends DatePicker {

public DatePickerCustom() {
    super();
}

public TextButton getTodayButton() {
    return this.todayBtn;
}

}


Update for DateField, I haven't tried but It is going to be bit complex DatePicker attached to DateMenu then DateMenu attached to DateField through DateCell. You have to extend these class to set customised DatePicker behaviour. Pass the extented DateCell instance to create DateField object.

nayakam
  • 4,149
  • 7
  • 42
  • 62
  • Logically looks perfect to resolve the problem, but some where/how it again giving the original behavior, even after overriding as per your suggestion. Any ideas on where it is resets the behavior? – Varun Tamiri Feb 13 '15 at 04:11
  • Can you post ur code please? You could remove tooltip where you define DatePickerCustom instance. – nayakam Feb 13 '15 at 04:46
  • I tried with Datepicker as I suggested. it worked. Please update the question with your code and problem. – nayakam Feb 16 '15 at 02:42
  • DatePicker defined in DateMenu. I think you have overide DateMenu set the custom date picker. http://grepcode.com/file/repo1.maven.org/maven2/com.sencha.gxt/gxt/3.1.1/com/sencha/gxt/widget/core/client/menu/DateMenu.java#DateMenu – nayakam Feb 16 '15 at 03:11
  • Can be used with DateField as well, but anyway I've update my question, please help. – Varun Tamiri Feb 16 '15 at 03:39
  • Look like your DateFieldCustom class desn't compile – nayakam Feb 16 '15 at 22:53
  • Is that for `picker.getTodayButton()...` ? – Varun Tamiri Feb 17 '15 at 02:01