Hi Daniil...
I create a btnOk ('Ok' button) and a btnCancel ('Cancel' button) in a window... Ok button confirm the changed in records and cancel button close without save changes...
The unwanted behavior what I am having is the following:
1 - The 'blur' event of txtCPF, (CPF - Cadastro de Pessoa Física - Individual ID for any person of Brazil... like the SSN in USA), call a procedure when I try find a customer in my DB with the CPF number and if the customer is found, the field txtDevedor is filled... otherwise, the 'Customer Window' is started for add a new customer.
2 - When cancel button is clicked (I want close the window only, cancel adding of new record), the 'blur' event of txtCPF is fired..
which is an undesirable situation...
The code of my Window follow:
<ext:Window
ID="wndDividas"
runat="server"
Icon="MoneyAdd"
Title="Dívida"
Width="590"
Height="370"
AutoShow="false"
Modal="true"
Resizable="false"
PaddingSummary="5px 5px 5px 5px"
Hidden="true"
ButtonAlign="Right"
Layout="FitLayout">
<Items>
<ext:Panel ID="Panel1" runat="server" Border="true" BodyPadding="6" Header="false">
<Items>
<ext:FieldSet runat="server" ID="fsContrato" Title="Informações do Contrato" Layout="AbsoluteLayout" Height="190px" PaddingSummary="5px 5px 5px 5px">
<Defaults>
<ext:Parameter Name="LabelAlign" Value="Top" Mode="Value" />
</Defaults>
<Items>
<ext:ComboBox runat="server" ID="cmbTipoPessoa" FieldLabel="Tipo" X="5" Y="0" Width="120px">
<Items>
<ext:ListItem Text="Pessoa" Value="1" />
<ext:ListItem Text="Empresa" Value="0" />
</Items>
<SelectedItems>
<ext:ListItem Value="0" />
</SelectedItems>
<DirectEvents>
<Select OnEvent="SetCPForCNPJ"/>
</DirectEvents>
</ext:ComboBox>
<ext:TextField runat="server" ID="txtCPF" EnableKeyEvents="true" FieldLabel="CNPJ" x="135" Y="0" Width="140px" Validator="ValidaCPF_CNPJ" ValidateOnBlur="true">
<Listeners>
<KeyUp Fn="KeyUpHandler" />
</Listeners>
<DirectEvents>
<Blur OnEvent="GetDevedor">
<EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{wndDividas}.body}" />
</Blur>
</DirectEvents>
</ext:TextField>
<ext:TextField runat="server" ID="txtDevedor" FieldLabel="Devedor" Disabled="true" DisabledClass="x-item-disable" x="285" Y="0" Width="225px" />
<ext:Toolbar ID="Toolbar1" runat="server" Cls="form-toolbar" Flat="true" X="512" Y="15">
<Items>
<ext:Button ID="btnDevedorEdit" runat="server" Text="" Icon="ApplicationEdit" >
<DirectEvents>
<Click OnEvent="Edit_Devedor" />
</DirectEvents>
</ext:Button>
</Items>
</ext:Toolbar>
<ext:TextField runat="server" ID="txtContrato" FieldLabel="Contrato Nº" MaxLength="30" x="5" Y="45" Width="80px" />
<ext:DateField runat="server" ID="dtVencimentoOriginal" FieldLabel="Vencimento Original" LabelWidth="120" AltFormats="d/m/Y|j/n/Y|j/n/y|j/m/y|d/n/y|j/m/Y|d/m/Y|d-m-y|d-m-Y|d/m|d-m|dm|dmy|dmY|d|d-m-Y" Format="dd/MM/yyyy" X="95" Y="45" Width="120px"/>
<ext:TextField runat="server" ID="txtJuro" FieldLabel="Juro (%)" Text="0,00" MaxLength="10" FieldStyle="text-align:right" EnableKeyEvents="true" X="225" Y="45" Width="85px">
<Listeners>
<KeyUp Fn="KeyUpHandler_Money" />
</Listeners>
</ext:TextField>
<ext:TextField runat="server" ID="txtMulta" FieldLabel="Multa (%)" Text="0,00" MaxLength="10" FieldStyle="text-align:right" EnableKeyEvents="true" X="320" Y="45" Width="85px">
<Listeners>
<KeyUp Fn="KeyUpHandler_Money" />
</Listeners>
</ext:TextField>
<ext:DateField runat="server" ID="dtDataCobranca" FieldLabel="Data de Cobrança" AltFormats="d/m/Y|j/n/Y|j/n/y|j/m/y|d/n/y|j/m/Y|d/m/Y|d-m-y|d-m-Y|d/m|d-m|dm|dmy|dmY|d|d-m-Y" Format="dd/MM/yyyy" X="415" Y="45" Width="120px" />
<ext:TextArea runat="server" ID="txtObservacoes" FieldLabel="Observações" MaxLength="150" EmptyText="Insira aqui informações que agilizem a cobrança da dívida." X="5" Y="90" Height="40" Width="530" />
<ext:DisplayField runat="server" ID="dsMsg" X="5" Y="150" Width="500px" FieldStyle="font-size:9px" Text="*O número do contrato identifica a dívida junto ao cliente(loja). Pode ser o nº da nota fiscal, duplica, cheque, etc." />
</Items>
</ext:FieldSet>
<ext:FieldSet runat="server" ID="fsParcela" Title="Parcela" Layout="AbsoluteLayout" Height="95px" PaddingSummary="5px 5px 5px 5px">
<Defaults>
<ext:Parameter Name="LabelAlign" Value="Top" Mode="Value" />
</Defaults>
<Items>
<ext:TextField runat="server" ID="txtParcelaNumero" MaxLength="30" FieldLabel="Parcela" X="5" Y="0" Width="120px" />
<ext:TextField runat="server" ID="txtParcelaDescricao" MaxLength="100" FieldLabel="Descrição" X="135" Y="0" Width="250px" />
<ext:TextField runat="server" ID="txtValor" FieldLabel="Valor (R$)" MaxLength="15" Text="0" FieldStyle="text-align:right" EnableKeyEvents="true" X="395" Y="0" Width="140px">
<Listeners>
<KeyUp Fn="KeyUpHandler_Money" />
</Listeners>
</ext:TextField>
<ext:Checkbox runat="server" ID="chkSpc" HideLabel="true" X="5" Y="45" />
<ext:DisplayField runat="server" ID="dsChkSpc" X="25" Y="47" Text="Inscrito no Serviço de Proteção ao Crédito - SPC" />
</Items>
</ext:FieldSet>
</Items>
</ext:Panel>
</Items>
<Buttons>
<ext:Button runat="server" id="btnOk" text="Ok" Width="80px" Icon="Tick">
<DirectEvents>
<Click OnEvent="SaveDivida" Failure="Ext.MessageBox.alert('Saving failed', 'Error during ajax event');">
<EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{wndDividas}.body}" />
</Click>
</DirectEvents>
</ext:Button>
<ext:Button runat="server" id="btnCancel" text="Cancelar" Width="80px" Icon="Cancel">
<DirectEvents>
<Click OnEvent="Cancel_Click" />
</DirectEvents>
</ext:Button>
</Buttons>
</ext:Window>