PDA

View Full Version : [CLOSED] FormPanel not validate a TextField after show with allowBlank = "false"



osef
Aug 01, 2014, 12:05 AM
Hi, I have the next problem, I have a FormPanel with a Button, the Button is Enabled when de FormPanel is valid, but I have a ComboBox with a Items, when I select the item "OTRO" a TextField2 is show, the TextField2 has a property AllowBlank="true", but when is show it has AllowBlank="false" from JavaScript, the problem is, when I show the TextField2 has blank text, but the FormPanel in ValidityChange is not working, this is my example:



<ext:FormPanel
ID="FormPanel1"
runat="server"
ButtonAlign="Right"
Height="185"
Padding="5"
Title="Title"
Width="300">
<Items>
<ext:TextField
ID="TextField1"
runat="server"
AnchorHorizontal="100%"
FieldLabel="Label"
AllowBlank="false">
</ext:TextField>
<ext:ComboBox
ID="cmbTipoParticipante"
runat="server"
AnchorHorizontal="100%"
AllowBlank="False"
QueryMode="Local"
TypeAhead="True"
ForceSelection="true"
MarginSpec="10px 0px 0px 10px"
EmptyText="Tipo participante"
Editable="False">
<ListConfig Cls="comboBoxCustom">
</ListConfig>
<Listeners>
<Select Fn="cmbTipoParticipante_Select" />
</Listeners>
<Items>
<ext:ListItem Text="PRODUCTOR" Value="1" />
<ext:ListItem Text="EXPOSITOR" Value="2" />
<ext:ListItem Text="PATROCINADOR" Value="3" />
<ext:ListItem Text="CONFERENCISTA" Value="4" />
<ext:ListItem Text="ASISTENTE POR PARTE DE UNA EMPRESA" Value="5" />
<ext:ListItem Text="INVESTIGADOR" Value="6" />
<ext:ListItem Text="OTRO" Value="7" />
</Items>
</ext:ComboBox>
<ext:TextField
ID="TextField2"
runat="server"
AnchorHorizontal="100%"
FieldLabel="Label"
AllowBlank="true"
Hidden="true">
</ext:TextField>
</Items>
<Listeners>
<ValidityChange Handler="this.dockedItems.get(1).setStatus({
text : valid ? 'La informaci?n esta completa/correcta' : 'Existen informaci?n incompleta/incorrecta',
iconCls: valid ? 'icon-accept' : 'icon-exclamation'
});
#{Button1}.setDisabled(!valid);" />
</Listeners>
<BottomBar>
<ext:StatusBar ID="sbRegistro" runat="server" />
</BottomBar>
<Buttons>
<ext:Button
ID="Button1"
runat="server"
Icon="Disk"
Text="Submit"
Disabled="true">
</ext:Button>
</Buttons>
</ext:FormPanel>




var cmbTipoParticipante_Select = function (combo, records) {
//6. Validaci?n para mostrar el campo de especificar otro tipo de participante
if (records[0].get('field1') === '7') {
App.TextField2.allowBlank = false;
App.TextField2.show();
App.TextField2.focus(false, 50);
}
};



When I Select the item "PRODUCTOR" is showing the button in enabled

http://forums.ext.net/attachment.php?attachmentid=13891&stc=1


But, after I select the item "OTRO" is showing the button in enabled, I want that the Listener ValidityChange is working because I set the allowBlank = 'true' in the TextField2.

http://forums.ext.net/attachment.php?attachmentid=13901&stc=1

Could you please help me?

Thnak you

Daniil
Aug 01, 2014, 5:37 AM
Hi @osef,

If you change some validation property like AllowBlank on the fly, you should re-validate to get that change taken into account.

I would try this:

App.TextField2.allowBlank = false;
App.TextField2.validate();