confirmation message from the event gridpanel RowCommand

Page 1 of 2 12 LastLast
  1. #1

    confirmation message from the event gridpanel RowCommand

    Gentlemen,

    nesecito before running the delete, I asked if you want and if you want to delete the record otherwise not.

    this attempt to do so from a command event of a gridpanel.

    this is my code.

    protected void Command(object sender, DirectEventArgs e)
        {
                 
           string fileWatchID = e.ExtraParams["id"];
           string comando = e.ExtraParams["command"];
            
           if(comando == "Delete")
           {           
                   Ent_Maestro oentidad = new Ent_Maestro();
                   oentidad.Id_categoria = Convert.ToInt32(fileWatchID);
                   onegocio_M.Eliminar_Categoria(oentidad);
                   Listar_Todo_Cat_Grid();
                   X.Msg.Notify("Notificacion", "Registro Eliminado Correctamente.").Show();
                   limpiarform_cat();           
           }            
           else
           {
               if (comando == "Edit")
               {
                   int ID_CATEGORIA = Convert.ToInt32(fileWatchID);
                   Ent_Maestro oentidad = new Ent_Maestro();
                   DataSet tabla = new DataSet();
                   oentidad.Id_categoria = ID_CATEGORIA;
                   tabla = onegocio_M.Buscar_Categoria_Id(oentidad);
                   txtid_cat.Text = tabla.Tables[0].Rows[0]["ID_CATEGORIA"].ToString();
                   txtdec_cat.Text = tabla.Tables[0].Rows[0]["DESC_CATEGORIA"].ToString();
                   txtprov_cat.Text = tabla.Tables[0].Rows[0]["NOM_PROVEEDOR"].ToString();
                   txtresp_cat.Text = tabla.Tables[0].Rows[0]["NOM_RESPONSABLE"].ToString();
               }
           
           }
    many thanks in advance.
  2. #2
    Hi,

    Just ask a use within Command listener or Before handler of DirectEvent.

    Returning false from them stops a DirectEvent.
  3. #3

    example

    please give me an example of firing a confirmation from the sale of csharp code before executing the erase such.

    many thanks.
  4. #4
    I told about a confirmation on client side to prevent DirectEvent.
  5. #5
    Also you can use <Confirmation> of DirectEvent.

    See the second button:
    https://examples1.ext.net/#/Events/D...ents/Overview/
  6. #6
    my problem is that I can not do so, because I have 2 events command and should only ask if the event confirmation is with the delete button on the edit button should not ask anything.
  7. #7
    "command" argument is also available in Command listener, Before handler and BeforeConfim handler. You can check it.
  8. #8
    protected void Command(object sender, DirectEventArgs e)
        {
                  
           string fileWatchID = e.ExtraParams["id"];
           string comando = e.ExtraParams["command"];
             
           if(comando == "Delete")
           {  
    /*here I need to display the confirmation window,
     if results confirmed delete otherwise do nothing*/
             
                   Ent_Maestro oentidad = new Ent_Maestro();
                   oentidad.Id_categoria = Convert.ToInt32(fileWatchID);
                   onegocio_M.Eliminar_Categoria(oentidad);
                   Listar_Todo_Cat_Grid();
                   X.Msg.Notify("Notificacion", "Registro Eliminado Correctamente.").Show();
                   limpiarform_cat();           
           }            
           else
           {
               if (comando == "Edit")
               {
                   int ID_CATEGORIA = Convert.ToInt32(fileWatchID);
                   Ent_Maestro oentidad = new Ent_Maestro();
                   DataSet tabla = new DataSet();
                   oentidad.Id_categoria = ID_CATEGORIA;
                   tabla = onegocio_M.Buscar_Categoria_Id(oentidad);
                   txtid_cat.Text = tabla.Tables[0].Rows[0]["ID_CATEGORIA"].ToString();
                   txtdec_cat.Text = tabla.Tables[0].Rows[0]["DESC_CATEGORIA"].ToString();
                   txtprov_cat.Text = tabla.Tables[0].Rows[0]["NOM_PROVEEDOR"].ToString();
                   txtresp_cat.Text = tabla.Tables[0].Rows[0]["NOM_RESPONSABLE"].ToString();
               }
            
           }
    is this possible?
    how do I ask if the command is todelete fire confimacion window ,only to delete ?
    Last edited by Daniil; Jun 01, 2011 at 1:42 PM. Reason: Please use [CODE] tags
  9. #9
    Here you are.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "test11", "test12", "test13" },
                    new object[] { "test12", "test22", "test23" },
                    new object[] { "test13", "test32", "test33" }
                };
                store.DataBind();
            }
        }
    
        protected void GridPanel1_Command(object sender, DirectEventArgs e)
        {
            string c = e.ExtraParams["command"];
            string id = e.ExtraParams["id"];
            switch (c)
            {
                case "delete":
                {
                    X.Msg.Alert("Deleted", "Record " + id + " is deleted.").Show();
                    break;
                }
                case "save":
                {
                    X.Msg.Alert("Saved", "Record " + id + " is saved.").Show();
                    break;
                }   
            }
            
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test1" />
                                <ext:RecordField Name="test2" />
                                <ext:RecordField Name="test3" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Header="Test1" DataIndex="test1" />
                    <ext:Column Header="Test2" DataIndex="test2" />
                    <ext:Column Header="Test3" DataIndex="test3" />
                    <ext:ImageCommandColumn Width="50" Align="Center">
                        <Commands>
                            <ext:ImageCommand CommandName="delete" Icon="Delete" />
                            <ext:ImageCommand CommandName="save" Icon="Disk" />
                        </Commands>
                    </ext:ImageCommandColumn>
                </Columns>
            </ColumnModel>
            <DirectEvents>
                <Command OnEvent="GridPanel1_Command">
                    <ExtraParams>
                        <ext:Parameter Name="command" Value="command" Mode="Raw" />
                        <ext:Parameter Name="id" Value="record.id" Mode="Raw" />
                    </ExtraParams>
                    <Confirmation 
                        ConfirmRequest="true" 
                        Message="Are you sure?" 
                        BeforeConfirm="return command ==='delete';" />
                </Command>
            </DirectEvents>
        </ext:GridPanel>
        </form>
    </body>
    </html>
  10. #10
    many thanks,
    excellent service and I have no how to thank you.

    really thanks.
    Last edited by geoffrey.mcgill; Jun 01, 2011 at 5:41 PM.
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] [1.0] Confirmation Message
    By vali1993 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 30, 2011, 4:46 PM
  2. [CLOSED] Confirmation Message
    By FpNetWorth in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Mar 04, 2011, 12:58 PM
  3. Replies: 3
    Last Post: Aug 18, 2010, 9:34 PM
  4. Customize WarningOnDirty confirmation message
    By fquintero in forum 1.x Help
    Replies: 5
    Last Post: Nov 01, 2009, 2:57 PM
  5. [CLOSED] Confirmation message question
    By methode in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 06, 2009, 8:23 AM

Posting Permissions