[CLOSED] ValidateEdit After MessageBox with focus

  1. #1

    [CLOSED] ValidateEdit After MessageBox with focus

    Hi, I have a problem with GridPanel with CellEditing, I am validating in field ID when is blank, so, I triger a MessageBox when this is sucess, but when the MessageBox is triger I have the focus in Cell ID, so, I press the enter key the field is edit state I want the field is not editing Can you help me please?

    This is the new row with the button, the field ID is blank



    When I press the enter key with the field ID in blank, It is throw MessageBox, but I press the enter key and the field ID is editing



        <script type="text/javascript">
            //Validar la edici?n o un nuevo registro
            var validateEdit_Registro = function (editor, context) {
                var store = App.gpGruposMenu.getStore();
    
                //Si el campo a validar es el ID
                if (context.field == 'ID') {
                    //Si es vacio lanzar un error
                    if (context.value == '') {
                        Ext.Msg.show({
                            id: 'msgID',
                            title: 'Error',
                            msg: 'Debes capturar un ID',
                            buttons: Ext.MessageBox.OK,
                            onEsc: Ext.emptyFn,
                            closable: false,
                            icon: Ext.MessageBox.ERROR
                        });
                    }
                }
            };
    
            //Insertar un nuevo registro en blanco
            var click_insertarRegistro = function () {
                //Get store of gridpanel
                var store = App.gpGruposMenu.getStore();
                //Get the total records
                var total = store.getCount();
    
                //Insert new record in the final
                store.insert(total, {});
                App.gpGruposMenu.getView().focusRow(total);
                App.gpGruposMenu.editingPlugin.startEdit(store.getAt(total), App.gpGruposMenu.columns[0]);
            };
        </script>
    
           <ext:GridPanel
                ID="gpGruposMenu"
                runat="server"
                Height="420"
                Width="960"
                Title="GRUPOS MEN?"
                EnableColumnHide="false"
                EnableColumnMove="false"
                Header="true"
                TitleAlign="Left">
                <TopBar>
                    <ext:Toolbar ID="tbGruposMenu" runat="server">
                        <Items>
                            <ext:Button
                                ID="New"
                                runat="server"
                                Height="50"
                                Width="50"
                                Text="Nuevo">
                                <Listeners>
                                    <Click Fn="click_insertarRegistro" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Store>
                    <ext:Store
                        ID="sGruposMenu"
                        runat="server">
                        <Model>
                            <ext:Model ID="mGruposMenu" runat="server">
                                <Fields>
                                    <ext:ModelField Name="ID" Type="String" />
                                    <ext:ModelField Name="Descripcion" Type="String" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel>
                    <Columns>
                        <ext:Column 
                            ID="cID"
                            runat="server"
                            Text="ID"
                            Align="Center"
                            Width="100"
                            DataIndex="ID">
                            <Editor>
                                <ext:TextField
                                    ID="txtID"
                                    runat="server"
                                    MaxLength="3"
                                    EnforceMaxLength="true">
                                    <Listeners>
                                        <Blur Handler="App.txtID.setValue(App.txtID.getValue().toUpperCase());" />
                                    </Listeners>
                                </ext:TextField>
                            </Editor>
                        </ext:Column>
                        <ext:Column
                            ID="cDescripcion"
                            runat="server"
                            Text="DESCRIPCI?N"
                            Align="Left"
                            Width="858"
                            DataIndex="Descripcion">
                            <Editor>
                                <ext:TextField
                                    ID="txtDescripcion"
                                    runat="server"
                                    MaxLength="50"
                                    EnforceMaxLength="true">
                                    <Listeners>
                                        <Blur Handler="App.txtDescripcion.setValue(App.txtDescripcion.getValue().toUpperCase());" />
                                    </Listeners>
                                </ext:TextField>
                            </Editor>
                        </ext:Column>
                    </Columns>
                </ColumnModel>
                <View>
                    <ext:GridView
                        ID="gvGruposMenu"
                        runat="server"
                        StripeRows="true"
                        AllowDeselect="true">
                    </ext:GridView>
                </View>
                <Plugins>
                    <ext:CellEditing ID="ceGruposMenu" runat="server" ClicksToEdit="2">
                        <Listeners>
                            <ValidateEdit Fn="validateEdit_Registro"  />
                        </Listeners>
                    </ext:CellEditing>
                </Plugins>
                <SelectionModel>
                    <ext:RowSelectionModel
                        ID="rsmGruposMenu"
                        runat="server"
                        AllowDeselect="true">
                    </ext:RowSelectionModel>
                </SelectionModel>
            </ext:GridPanel>
    
            protected void Page_Load(object sender, EventArgs e)
            {
                List<GrupoMenu> lGrupoMenu = new List<GrupoMenu>();
                for (int i = 0; i <= 5; i++)
                {
                    GrupoMenu oGrupoMenu = new GrupoMenu();
                    oGrupoMenu.ID = "id" + i;
                    oGrupoMenu.Descripcion = "descripci?n" + i;
                    lGrupoMenu.Add(oGrupoMenu);
                }
    
                sGruposMenu.DataSource = lGrupoMenu;
                sGruposMenu.DataBind();
            }
    
            public class GrupoMenu
            {
                public string ID
                {
                    get;
                    set;
                }
    
                public string Descripcion
                {
                    get;
                    set;
                }
            }
    Attached Thumbnails Click image for larger version. 

Name:	ErrorFocus01.png 
Views:	26 
Size:	9.9 KB 
ID:	16141   Click image for larger version. 

Name:	ErrorFocus02.png 
Views:	34 
Size:	14.2 KB 
ID:	16151  
    Last edited by Daniil; Nov 13, 2014 at 6:51 AM. Reason: [CLOSED]
  2. #2
    Hi @osef,

    Please try:
    <ValidateEdit Fn="validateEdit_Registro" Delay="1" />
  3. #3
    This is working Daniil, thank you.

Similar Threads

  1. Replies: 13
    Last Post: Feb 05, 2014, 2:59 AM
  2. [CLOSED] ValidateEdit in EditGrid issue
    By capbarbell in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: May 14, 2013, 11:02 AM
  3. GridPanel ValidateEdit Problem
    By cath he dash hai in forum 1.x Help
    Replies: 3
    Last Post: Nov 04, 2012, 3:02 AM
  4. ValidateEdit Fires even if value is unmodified
    By nanosassa in forum 1.x Help
    Replies: 1
    Last Post: Aug 24, 2009, 1:18 PM
  5. Replies: 3
    Last Post: Feb 09, 2009, 11:42 AM

Tags for this Thread

Posting Permissions