Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Ext GWT Premium Member
    Join Date
    Aug 2010
    Posts
    31
    Vote Rating
    0
    marrrck is on a distinguished road

      0  

    Default How To dynamically hide/show one TwinTriggerField trigger

    How To dynamically hide/show one TwinTriggerField trigger


    Hi Everyone,

    I'm very new to GXT but I'm working on a proof-of-concept port of an existing Ext JS/Stripes app to GXT. In our existing app we have a search box that uses a twin trigger field, and we only show the second trigger (cancel button) after the user has typed something in the box. We have this working in Ext JS, but I haven't figured out how to do it in GXT. I've got an event listener that changes the trigger field style class but it doesn't seem to be sticking. I'm hoping it is something else I'm just forgetting to call to get the style change to actually take effect?

    Code:
    public class SearchTwinTriggerField extends TwinTriggerField<String> {
    
      public SearchTwinTriggerField() {
        super();
        setTriggerStyle("dx-form-search-trigger");
        hideClearTrigger();
        setFieldLabel("Search");
    
        KeyListener keyListener = new KeyListener() {
    
          @Override
          public void componentKeyPress(ComponentEvent event) {
            if (!event.isSpecialKey()) {
              showClearTrigger();
            }
          }
    
        };
        addKeyListener(keyListener);
      }
    
      public void showClearTrigger() {
        setTwinTriggerStyle("dx-form-clear-trigger");
    // tried all of these but nothing seems to work.
        repaint();
        show();
        render(getElement());
      }
    
      public void hideClearTrigger() {
        setTwinTriggerStyle("dx-form-clear-trigger-hide");
      }
    }
    I've also tried updating the style on the trigger field (not the twin trigger) but that didn't help either. I've also tried using the hide methods on TriggerField, but that seems to hide both the buttons.

    Any help would be greatly appreciated

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    It would be something like this:
    Code:
    class SearchTwinTriggerField extends TwinTriggerField<String> {
    
      public SearchTwinTriggerField() {
        super();
        setTriggerStyle("dx-form-search-trigger");
        setTwinTriggerStyle("dx-form-clear-trigger");
        setFieldLabel("Search");
    
        final DelayedTask task = new DelayedTask(new Listener<BaseEvent>() {
          public void handleEvent(BaseEvent be) {
            if (getRawValue() != null && getRawValue().length() > 0) {
              showClearTrigger();
            } else {
              hideClearTrigger();
            }
          }
        });
    
        KeyListener keyListener = new KeyListener() {
          @Override
          public void componentKeyPress(ComponentEvent event) {
            task.delay(100);
          }
    
        };
        addKeyListener(keyListener);
      }
    
      public void showClearTrigger() {
        twinTrigger.removeStyleName("dx-form-clear-trigger-hide");
        twinTrigger.setStyleAttribute("display", "");
        syncSize();
      }
    
      @Override
      protected Size adjustInputSize() {
        return new Size(isHideTrigger() ? 0
            : ((trigger.isVisible(false) ? trigger.getStyleSize().width : 0) + (twinTrigger.isVisible(false)
                ? twinTrigger.getStyleSize().width : 0)), 0);
      }
    
      @Override
      protected void onRender(Element target, int index) {
        super.onRender(target, index);
    
        hideClearTrigger();
      }
    
      public void hideClearTrigger() {
        twinTrigger.addStyleName("dx-form-clear-trigger-hide");
        twinTrigger.hide();
        syncSize();
      }
    }

  3. #3
    Ext GWT Premium Member
    Join Date
    Aug 2010
    Posts
    31
    Vote Rating
    0
    marrrck is on a distinguished road

      0  

    Default


    Thanks for the quick reply sven! That worked like a charm. I should have checked the source for those protected variables! Thanks for your help!

  4. #4
    Sencha User chalu's Avatar
    Join Date
    Feb 2008
    Location
    Benin City, Nigeria
    Posts
    480
    Vote Rating
    1
    chalu is on a distinguished road

      0  

    Default


    This is also related to what I've been wanting to do, which is to change the trigger / drop-down icon of a combo when it's been loaded to something that reflects that state, guess I'll just have to add a listener to the store and use setTriggerStyle() to change the icon appropriately.

    Just some questions about this :
    Is there a ready-to-use css rule to show the loading state, like there is "dx-form-search-trigger" for search.

    Do I have to make a subclass just for this, Ext Js has the idea of "overrides" where I can setup code to override a behavior in a class causing all instances of that class to have the override. That way this can be one without sub-classing.

  5. #5
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Changing the triggericon is much easier. Simple add/remove an additional classname to the trigger element that sets another background image.

  6. #6
    Sencha User chalu's Avatar
    Join Date
    Feb 2008
    Location
    Benin City, Nigeria
    Posts
    480
    Vote Rating
    1
    chalu is on a distinguished road

      0  

    Default


    Yes seven, but doing this manually for every combo can be tedious, would be better to do it once (attaching the store listener and changing the icon when needed) and have all combos behave that way, but it appears that with Java the only way to inherit implementation is via subclassing, is there any other construct, I am thinking of making this a topic in GWT open discussion forum, Thanks

  7. #7
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    When you want to change the behaviour, you need to subclass it. But that should not be a problem. You only need to subclass it once and use this new class everywhere.

  8. #8
    Sencha User chalu's Avatar
    Join Date
    Feb 2008
    Location
    Benin City, Nigeria
    Posts
    480
    Vote Rating
    1
    chalu is on a distinguished road

      0  

    Default


    Yeah, you are absolutely correct, but I'll now be required to change all instances of ComboBox to the new one (maybe XComboBox).

  9. #9
    Sencha User
    Join Date
    Jan 2012
    Posts
    4
    Vote Rating
    0
    GEqui is on a distinguished road

      0  

    Default


    Could you guys please provide some details on how i :
    "Simple add/remove an additional classname to the trigger element that sets another background image"

    Thanx lots

Similar Threads

  1. How to dynamically hide/show trigger on trigger field?
    By netslayer in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 2 Aug 2010, 11:32 AM
  2. How to show/hide fieldLabel dynamically ?
    By Ash2009 in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 26 Oct 2009, 2:54 PM
  3. Hide and show a combobox dynamically?
    By whdanj in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 6 May 2009, 9:33 AM
  4. show/hide tabpanelItem dynamically
    By rajeshin in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 26 Sep 2008, 3:58 AM

Thread Participants: 3