1. #1
    Sencha User
    Join Date
    Sep 2009
    Posts
    289
    Vote Rating
    0
    diegolovison is on a distinguished road

      0  

    Default tab panel + form validation

    tab panel + form validation


    click in the button "validate" will return false...
    open the other tab and click in the button "validate" will return true..

    its correct?

    xp
    hosted mode
    gxt 2.0.1
    gwt 1.7.0

    Code:
        @Override
        public void onModuleLoad() {
    
            final TextField<String> field = new TextField<String>();
            field.setAllowBlank(false);
            field.setValue("my field");
    
            final FormPanel formPanel = new FormPanel();
            formPanel.add(field);
    
            final TabItem tabItem1 = new TabItem();
            tabItem1.setText("no field");
            final TabItem tabItem2 = new TabItem();
            tabItem2.setText("with field");
            tabItem2.add(formPanel);
    
            final TabPanel tabPanel = new TabPanel();
            tabPanel.add(tabItem1);
            tabPanel.add(tabItem2);
            tabPanel.setSize(400, 200);
    
            final Button button = new Button("validate", new SelectionListener<ButtonEvent>() {
                @Override
                public void componentSelected(final ButtonEvent ce) {
    
                    final Boolean valid = formPanel.isValid();
    
                    Window.alert(valid.toString());
                }
            });
    
            RootPanel.get().add(tabPanel);
            RootPanel.get().add(button);
        }

  2. #2
    Sencha User
    Join Date
    Sep 2009
    Posts
    289
    Vote Rating
    0
    diegolovison is on a distinguished road

      0  

    Default


    to solve this use deferred render equals false..

    HTML Code:
    True to render each child tab item when it accessed, false to render all  (defaults to true). Setting to false would be useful when using forms as  validation would need to be applied to all children even if they had not  been selected. 
    but setting deferrend render equals false return a layout problem when use combobox into a form panel, your size its bigger than the other fields

    test the source code
    Code:
        @Override
        public void onModuleLoad() {
    
            final TextField<String> field = new TextField<String>();
            field.setAllowBlank(false);
            field.setValue("my field");
    
            final ComboBox<ModelData> combo = new ComboBox<ModelData>();
            combo.setStore(new ListStore<ModelData>());
    
            final FormPanel formPanel = new FormPanel();
            formPanel.add(field);
            formPanel.add(combo);
    
            final TabItem tabItem1 = new TabItem();
            tabItem1.setText("no field");
    
            final TabItem tabItem2 = new TabItem();
            tabItem2.setText("with field");
            tabItem2.add(formPanel);
    
            final TabPanel tabPanel = new TabPanel();
            tabPanel.setDeferredRender(false);
            tabPanel.add(tabItem1);
            tabPanel.add(tabItem2);
            tabPanel.setSize(400, 200);
    
            final Button button = new Button("validate", new SelectionListener<ButtonEvent>() {
                @Override
                public void componentSelected(final ButtonEvent ce) {
    
                    final Boolean valid = formPanel.isValid();
    
                    Window.alert(valid.toString());
                }
            });
    
            RootPanel.get().add(tabPanel);
            RootPanel.get().add(button);
        }

  3. #3
    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


    You need to change the hidemode ot the tabitems to something different than display as workaround.

    GXT 2.0.2 has a workaround directly implemented.

  4. #4
    Sencha User
    Join Date
    Sep 2009
    Posts
    289
    Vote Rating
    0
    diegolovison is on a distinguished road

      0  

    Default


    sorry.. but this means that was corrected?

  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


    It was adjusted to work without modifications, yes. However the current behaviour is expected if something gets hidden with display none.

  6. #6
    Sencha User
    Join Date
    Sep 2009
    Posts
    289
    Vote Rating
    0
    diegolovison is on a distinguished road

      0  

    Default


    thanks

Thread Participants: 1