Display Value on Confirmation Prompt

  1. #1

    Display Value on Confirmation Prompt

    Dears,


    Hope you are doing well.

    Look at this code:

    <ext:Window 
                    ID="AddNewBidWindow" 
                    runat="server" 
                    Icon="MoneyDollar"
                    Hidden="true"
                    Closable="true"
                    Title="Submit New Bid"
                    Width="600"
                    MaxHeight="260"
                    PaddingSpec="0 0 0 0"
                    MarginSpec="0 0 0 0"
                    ClientIDMode="Static"
                    Resizable="true"
                    BodyStyle="background-color:#fff;"
                    BodyPadding="5"
                    Layout="Form">
                        <Listeners>
                            <Show Handler="positionWindow(this);"/>
                        </Listeners>
                        <Items>
                            <ext:FormPanel 
                                runat="server"
    			                ID="AddNewBidWindowPnl"
                                PaddingSpec="0 0 0 0"
                                MarginSpec="0 0 0 0"
                                MaxWidth="550"
                                MaxHeight="260"
                                Hidden="false"
                                Header="false"
                                ClientIDMode="Static"
                                Layout="FormLayout"
                                ButtonAlign="Right"
                                Frame="false" >
    			                    <Items>
    					                <ext:TextField 
    						                runat="server" 
                                            AllowBlank="false"
                                            ClientIDMode="Static"
    						                ID="txtNewBidValue" 
    						                FieldLabel="New Bid Value" 
                                            BlankText="Bid Value is Required"
    						                LabelAlign="Right" >
    					                </ext:TextField>
                                    </Items>
                                    <Buttons>
    	                                <ext:Button runat="server" Icon="Key" Text="Add"  >
    	                                <DirectEvents>
    		                                <Click OnEvent="addNewBid" IsUpload="true"  Before="if (#{AddNewBidWindowPnl}.getForm().isValid()) { return true; } else { return false; }">
    			                                <EventMask ShowMask="true" Msg="Adding..." Target="CustomTarget" CustomTarget="={#{AddNewBidWindowPnl}.body}" />
                                                <ExtraParams>                                             
                                                    <ext:Parameter 
                                                        Name="mytxtNewBidValue" 
                                                        Value="#{txtNewBidValue}.getValue()" 
                                                        Mode="Raw" 
                                                        Encode="false" />
                                                </ExtraParams>
                                                <Confirmation ConfirmRequest="true" Title="Confirm Bid Value" Message="Are you sure you want to submit the new bid value?" />
    		                                </Click>
    	                                </DirectEvents>
    	                                </ext:Button>
    		                            <ext:Button runat="server" Icon="Decline" Text="Cancel"  >
                                            <Listeners>
                                                <Click Fn="closeAddNewBidWindow" />
                                            </Listeners>
                                        </ext:Button>		                
    	                        </Buttons>
                            </ext:FormPanel>
                        </Items>
                </ext:Window>
    I want to display the value of Bid with confirmation message, how to achieve this?

    The massage shall be:

    Are you sure you want to submit the new bid value (X value from txtNewBidValue)?

    Regards,
  2. #2
    Hello @aliabdulla!

    Instead of adding the direct event straight to the add button, do add it to a window with an ok button, and display the window (you'll probably want to set it up as a modal). So the window's cancel button would just close that window, and the ok one would have the actual direct event.

    This should be simple enough for you to get going, but let us know if you are still not sure how to handle the scenario. There's really not much involved here. Just trigger the window display with the add click. Window's ok actually does the direct event. And the window can look just like a dialog prompt/alert box, maybe with buttons in a bbar block. You'll also want something like Before= you used in line 48 to close the window like cancel would.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello Again,

    I'm sorry but couldn't demonstrate your suggestion.

    Could you please add code snippet showing the idea?
  4. #4
    Dear @fabricio.murta,

    Thanks for your support.

    I need to finalize the above issue to meet my due date.

    Could you please help me?

    Regards,
  5. #5
    Hello again, @aliabdulla, and sorry for the long delay in getting back to you!

    Apologies for I didn't understand your question the first time I read thru. You already have the confirmation message the way you want and you just need to apply a variable value to the confirmation message.

    To attain that, just change your code sample line 57 to:

    <Confirmation ConfirmRequest="true" Title="Confirm Bid Value" BeforeConfirm="this.message='Are you sure you want to submit the new bid? Value: ' + App.txtNewBidValue.getValue();" />
    I believe this should be enough to get you going, but as we had all this delay to respond, I'll also add the full test case based on the code sample you provided:

    <%@ Page Language="C#" %>
    
    <script runat="server">
        public void addNewBid(object sender, DirectEventArgs e)
        {
            var newBidValue = e.ExtraParams["mytxtNewBidValue"];
    
            X.Toast("You made a new bid with value: " + newBidValue);
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Thread 63085 - Custom variable in confirmation dialog message.</title>
        <script type="text/javascript">
            var closeAddNewBidWindow = function () {
                App.AddNewBidWindow.hide();
            }
    
            var positionWindow = function () {
                Ext.toast("Window positioned.");
            }
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:Window 
                ID="AddNewBidWindow" 
                runat="server" 
                Icon="MoneyDollar"
                Hidden="false"
                Closable="true"
                Title="Submit New Bid"
                Width="600"
                MaxHeight="460"
                PaddingSpec="0 0 0 0"
                MarginSpec="0 0 0 0"
                ClientIDMode="Static"
                Resizable="true"
                BodyStyle="background-color:#fff;"
                BodyPadding="5"
                Layout="Form">
                    <Listeners>
                        <Show Handler="positionWindow(this);"/>
                    </Listeners>
                    <Items>
                        <ext:FormPanel 
                            runat="server"
                            ID="AddNewBidWindowPnl"
                            PaddingSpec="0 0 0 0"
                            MarginSpec="0 0 0 0"
                            MaxWidth="550"
                            MaxHeight="260"
                            Hidden="false"
                            Header="false"
                            ClientIDMode="Static"
                            Layout="FormLayout"
                            ButtonAlign="Right"
                            Frame="false" >
                                <Items>
                                    <ext:TextField 
                                        runat="server" 
                                        AllowBlank="false"
                                        ClientIDMode="Static"
                                        ID="txtNewBidValue" 
                                        FieldLabel="New Bid Value" 
                                        BlankText="Bid Value is Required"
                                        LabelAlign="Right"
                                        Reference="newBidValue">
                                    </ext:TextField>
                                </Items>
                                <Buttons>
                                    <ext:Button runat="server" Icon="Key" Text="Add" >
                                    <DirectEvents>
                                        <Click OnEvent="addNewBid" IsUpload="true"  Before="if (#{AddNewBidWindowPnl}.getForm().isValid()) { return true; } else { return false; }">
                                            <EventMask ShowMask="true" Msg="Adding..." Target="CustomTarget" CustomTarget="={#{AddNewBidWindowPnl}.body}" />
                                            <ExtraParams>                                             
                                                <ext:Parameter 
                                                    Name="mytxtNewBidValue" 
                                                    Value="#{txtNewBidValue}.getValue()" 
                                                    Mode="Raw" 
                                                    Encode="false" />
                                            </ExtraParams>
                                            <Confirmation ConfirmRequest="true" Title="Confirm Bid Value" BeforeConfirm="this.message='Are you sure you want to submit the new bid? Value: ' + App.txtNewBidValue.getValue();" />
                                        </Click>
                                    </DirectEvents>
                                    </ext:Button>
                                    <ext:Button runat="server" Icon="Decline" Text="Cancel"  >
                                        <Listeners>
                                            <Click Fn="closeAddNewBidWindow" />
                                        </Listeners>
                                    </ext:Button>
                            </Buttons>
                        </ext:FormPanel>
                    </Items>
            </ext:Window>
        </form>
    </body>
    </html>
    Hope this helps! And let us know if you still can't figure it out.

    It helps reduce answers delay and incorrectness if fully runnable test cases are provided whenever possible.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 9
    Last Post: Nov 23, 2012, 3:13 AM
  2. Replies: 3
    Last Post: Sep 20, 2011, 6:07 PM
  3. [CLOSED] Button DirectEvent Confirmation - display alert
    By bethc in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 28, 2010, 4:21 AM
  4. [CLOSED] Prompt before DirectEvent
    By rthiney in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 05, 2010, 4:33 PM
  5. Get the value from prompt dialog and save
    By CoolNoob in forum 1.x Help
    Replies: 5
    Last Post: Oct 23, 2009, 2:13 PM

Posting Permissions