[CLOSED] Conditional Confirmation

  1. #1

    [CLOSED] Conditional Confirmation

    Trying to find an example or combination of examples for my task:
    When the user clicks a button on a form, I need to throw a confirmation "are you sure?" window if specific fields are changed. In asp.net I would create hidden fields to store the initial values of the fields in question and then in javascript have a confirmation function that finds the control with document.getelementbyid and compares the hidden value to the new value throwing up confirmation if any have changed.
    Is there anything built into ext.net to do something similar? or should I basically recreate what I did with asp.net with ext controls?

    My searches have found entries dealing with validation and remote validation but it's not quite the same as a conditional confirmation.

    Thanks in advance,
    Robb
    Last edited by Daniil; Dec 12, 2011 at 2:47 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I recommend to use the isDirty method.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!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>
    
        <script type="text/javascript">
            var onSubmit = function (fp) {
                var form = fp.getForm(),
                    msg,
                    ids = "";
                if (form.isDirty()) {
                    msg = "The {0} field(-s) has been changed.<br/>Are you sure to continue?";
                    fp.items.each(function (f) {
                        if (f.toConfirm && f.isDirty()) {
                            ids += f.id + " ";
                        }
                    });
                    if (ids !== "") { 
                        Ext.Msg.confirm("Confirm?", String.format(msg, ids), function (btn) {
                            if (btn === "yes") {
                                submit();   
                            }
                        });
                        return;
                    }
                }
                submit();
            };
    
            var submit = function () {
                alert("Submitted");
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:FormPanel ID="FormPanel1" runat="server">
                <Items>
                    <ext:TextField runat="server" FieldLabel="Must not be confirmed" />
                    <ext:TextField 
                        ID="TextField1" 
                        runat="server" 
                        FieldLabel="Must be confirmed">
                        <CustomConfig>
                            <ext:ConfigItem Name="toConfirm" Value="true" Mode="Raw" />
                        </CustomConfig>
                    </ext:TextField>
                     <ext:TextField 
                        ID="TextField2" 
                        runat="server" 
                        FieldLabel="Must be confirmed">
                        <CustomConfig>
                            <ext:ConfigItem Name="toConfirm" Value="true" Mode="Raw" />
                        </CustomConfig>    
                    </ext:TextField>
                </Items>
            </ext:FormPanel>
            <ext:Button runat="server" Text="Submit">
                <Listeners>
                    <Click Handler="onSubmit(FormPanel1);" />
                </Listeners>
            </ext:Button>
        </form>
    </body>
    </html>
    See also
    http://docs.sencha.com/ext-js/3-4/#!...method-isDirty
    http://docs.sencha.com/ext-js/3-4/#!...method-isDirty
  3. #3

    MultiCombo selected Value

    Hello,

    I can not retrieve the selected values

    thanks for your help,
    Dif
  4. #4
    Hi @ahoussa87,

    Please start a new forum thread.
  5. #5
    Great, thanks for the example.

Similar Threads

  1. Conditional display of menu
    By olakara in forum 1.x Help
    Replies: 2
    Last Post: Apr 15, 2010, 3:23 AM
  2. [CLOSED] GridPanel conditional edit
    By sharif in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 20, 2010, 1:05 PM
  3. [CLOSED] CheckboxSelectionModel + conditional select
    By reinout.mechant@imprss.be in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 02, 2009, 6:09 AM
  4. Conditional AjaxEvents
    By grmontero in forum 1.x Help
    Replies: 1
    Last Post: May 29, 2009, 10:40 AM
  5. [CLOSED] Conditional AjaxEvent Confirmation
    By methode in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 20, 2009, 9:13 AM

Posting Permissions