Cancel insertion or editing of gridpanel

  1. #1

    Cancel insertion or editing of gridpanel

    Hi

    I have a gridpanel that displays a window to insert new record. It's working.
    But I have a cancel button only closes the window, I need data gridpanel be canceled by clicking this button

    Thanks

    Following partial code:

    <ext:Window 
        ID="CadastroProduto" 
        runat="server" 
        Icon="Group" 
        Title="Cadastro de Produtos"
        Width="400" 
        Height="400" 
        AutoShow="false" 
        Modal="true" 
        Hidden="true"
        Layout="Fit">
           <Items>    
                  <ext:FormPanel ID="FormPanel1" runat="server" Title="Form Panel" Padding="5" ButtonAlign="Right">
                                <Items>
                                    <ext:TextField ID="COD_PRODUTO" DataIndex="COD_PRODUTO" runat="server" FieldLabel="Código" AnchorHorizontal="95%" />
                                    <ext:TextField ID="DESCRICAO" DataIndex="DESCRICAO" runat="server" FieldLabel="Descrição" AnchorHorizontal="95%" />
                                    <ext:TextField ID="PRECO_CUSTO" DataIndex="PRECO_CUSTO" runat="server" FieldLabel="Preço Custo" AnchorHorizontal="95%" />
                                    <ext:TextField ID="PRECO_VENDA" DataIndex="PRECO_VENDA" runat="server" FieldLabel="Preço Venda" AnchorHorizontal="95%" />
                                    <ext:ComboBox ID="COD_MARCA2" runat="server" DataIndex="COD_MARCA" StoreID="Store2" TypeAhead="true" Mode="Local" ForceSelection="true" TriggerAction="All" DisplayField="DESCRICAO"  ValueField="COD_MARCA" EmptyText="Carregando..."  ValueNotFoundText="Carregando..."/>
                                   
                                </Items>
                                <Buttons>
                                    <ext:Button ID="Button10" runat="server" Text="Salvar">
                                        <Listeners>
                                           <Click Handler="#{FormPanel1}.getForm().updateRecord(#{GridPanel1}.getSelectionModel().getSelected());#{GridPanel1}.save();#{CadastroProduto}.hide()" />                                        
                                        </Listeners>
                                    </ext:Button>
                                    <ext:Button ID="Button4" runat="server" Text="Cancelar">
                                        <Listeners>
                                            <Click Handler="#{CadastroProduto}.hide();#{GridPanel1}.cancelRecord()" />                                        
                                        </Listeners>
                                    </ext:Button>
                                </Buttons>
                            </ext:FormPanel>
                         </Items>
                       </ext:Window>
  2. #2
    Hi,

    Call
    #{GridPanel1}.stopEditing(true);
  3. #3
    Hi Daniil,

    Thanks for helping me, but failed.
    When I click the cancel button (popup) the window is closed but the grid remains with the inserted row, and the row disappears only if I refresh the grid, instead of saving

    Thanks
  4. #4
    Hi,

    Yes, .stopEditing() doesn't remove new records. You have to do it manually.

    Refreshing data doesn't save data.

    See the example how to save:
    http://examples1.ext.net/#/GridPanel/Update/AutoSave/
    http://examples1.ext.net/#/GridPanel...SqlDataSource/
  5. #5
    Thanks Daniil, examples helped me solve

Similar Threads

  1. [CLOSED] Cancel TreePanel editing
    By RCN in forum 2.x Premium Help
    Replies: 7
    Last Post: Jun 26, 2012, 8:19 PM
  2. [CLOSED] Editing cell of gridPanel
    By supera in forum 2.x Premium Help
    Replies: 7
    Last Post: May 23, 2012, 12:47 PM
  3. How to change GridPanel editing row backcolor
    By kakagu in forum 1.x Help
    Replies: 0
    Last Post: May 08, 2012, 7:06 AM
  4. GridPanel Editor :- Stop editing on enter key
    By vivekrane1986 in forum 1.x Help
    Replies: 2
    Last Post: Oct 22, 2010, 9:50 AM
  5. Editing GridPanel attached to a SQLDatasource
    By tnwheeler in forum 1.x Help
    Replies: 2
    Last Post: Aug 30, 2010, 9:58 PM

Posting Permissions