views:

146

answers:

1

HI, I hope somebody can help me here with the extjs framework.

The problem I am having is that the field validation is not being rendered for the tabs that are not visibele on initialisation off the panel.

It only starts working when clicking in the textfields.

What I need is something to force the validation cue's for the fields on activating the tabs.

EDIT I came up with this

Ext.getCmp('aanMakenGebruikerTabPanel').on('tabchange',function(){
        AanMakenGebruikerWindow.syncShadow();
        Ext.getCmp('Mobiel1Veld').on('render',function(v){v.validate();});
        Ext.getCmp('Email1Veld').on('render',function(v){v.validate();});
        //console.log("[aanMakenGebruikerTabPanel] resize -- sync");
    });

EDIT I SOLVED IT BY USING THE CASCADE FUNCTION SO IT ALSO REACHES ITEMS IN A FIELDSET.

Ext.getCmp('aanMakenGebruikerTabPanel').on('tabchange',function(tabPanel,tab){
        AanMakenGebruikerWindow.syncShadow();
        tab.cascade(function(item) {
   if (item.isFormField) {
    item.validate();
  }
} );
    });

thanks, Richard

+1  A: 

In your Tab Panel config object add listeners for the beforetabchange/tabchange event. In the handler you have to iterate through the fields contained in the activated tab and trigger each field's validation. Hope this helps.

HOCA
I edited my question. Did you mean adding like that?I have to find out how to loop yet. So it's going forward.
Richard
Yes, that's the general idea. You can do it when you instantiate a new tabPanel in the config object as well. Refer to the api on the details of adding listeners object definition. You don't have to getCmp every time, the tabchange event provides a reference to the current tab/panel, which has a collection of its contained fields that you can iterate through and trigger validation. I believe the way you have it, the validation will only trigger the first time a tab is activated. You might not want to use the render event of the field to trigger the validation.
HOCA
I am trying to find out how the loop needs to work. Any suggestions? I will look at the config object later. I think that was something along the lines off listeners:{ 'eventname':function(){etc}}
Richard
Interesting, I haven't came across the cascade function before - looks like it's exactly what you'd want to use :)
HOCA