5 Replies Latest reply on Sep 9, 2009 6:41 AM by Ferrari_hunk

    Reset button in Flex

    gandhi.tush Level 1

      Hi,

      I am new to flex.

      I have an experience in working with HTML.

      In HTML we have a "reset" type of button, which reset to the previous values.

      Is it possible in flex?

      I want to do that functionality.

       

      Any help appreciated.

       

      Thanks,

      Tushar

        • 1. Re: Reset button in Flex
          Andrew Rosewarn Level 3

          Hi there

           

          Yes its possible.  Theres no reset button as such.  What you'd need to do is add a button and on its click event write a function to clear all of the fields in your form.

           

          Hope that helps

           

          Andrew

          • 2. Re: Reset button in Flex
            sergei_developer Level 1

            Check this example:

             

            <?xml version="1.0" encoding="utf-8"?>
            <!-- http://blog.flexexamples.com/2008/01/06/clearing-a-selected-radiobutton-control-in-flex/ -->
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    layout="vertical"
                    verticalAlign="middle"
                    backgroundColor="white">

                <mx:Script>
                    <![CDATA[
                        import mx.controls.Alert;

                        private function reset():void {
                            answers.selection = null;
                        }

                        private function check():void {
                            if (answers.selectedValue) {
                                Alert.show(answers.selectedValue.toString());
                            } else {
                                Alert.show("unselected");
                            }
                        }
                    ]]>
                </mx:Script>

                <mx:RadioButtonGroup id="answers" />

                <mx:Form backgroundColor="red">
                    <mx:FormItem>
                        <mx:Text id="question"
                                text="Question..." />
                    </mx:FormItem>
                    <mx:FormItem>
                        <mx:RadioButton id="answer1"
                                group="{answers}"
                                label="Answer 1" />
                    </mx:FormItem>
                    <mx:FormItem>
                        <mx:RadioButton id="answer2"
                                group="{answers}"
                                label="Answer 2" />
                    </mx:FormItem>
                    <mx:FormItem>
                        <mx:RadioButton id="answer3"
                                group="{answers}"
                                label="Answer 3" />
                    </mx:FormItem>
                    <mx:FormItem>
                        <mx:RadioButton id="answer4"
                                group="{answers}"
                                label="Answer 4" />
                    </mx:FormItem>
                    <mx:FormItem>
                        <mx:RadioButton id="answer5"
                                group="{answers}"
                                label="Answer 5" />
                    </mx:FormItem>
                    <mx:FormItem direction="horizontal">
                        <mx:Button label="Check" click="check();" />
                        <mx:Button label="Reset" click="reset();" />
                    </mx:FormItem>
                </mx:Form>

            </mx:Application>

            If this post answers your question or helps, please mark it as such.
            • 3. Re: Reset button in Flex
              Gregory Lafrance Level 6

              It depends on what you want. If you want to clear a bunch of TextInput, set a ComboBox to the selected value it had when the app first started, you need to code all that reset behavior in a method and then call that method as a click event handler for a Button.

               

              Depending on your intended behavior, you could use deep linking, which can be difficult to get to work, but once you do its great.

               

              http://labs.adobe.com/wiki/index.php/Flex_3:Feature_Introductions:_Deep_Linking

               

              http://livedocs.adobe.com/flex/3/html/help.html?content=deep_linking_1.html

               

              If this post answers your question or helps, please mark it as such.

              • 4. Re: Reset button in Flex
                gandhi.tush Level 1

                Hi Guys,

                I think there is confusion between what I am asking and what you have answered.

                You guys are talking about the Clearing the values  of textinput or combox. But I am talking about the resetting functionality.

                 

                These two are different things. Let me give the example:

                 

                "Suppose I have one Textbox which have prepopulated value as "ABC" or whatever during page load in browser. Then I have changed that value to "XYZ". And after that I clicked on "Reset Button". The behaviour of the reset button will be to restore the "ABC" in text input instead of clearing the value."

                 

                This is the behaviour of the reset button in HTML. I want this type of behaviour.

                Is it possible in Flex or not?

                 

                Any help appriciated.

                 

                Thanks,

                Tushar Gandhi

                • 5. Re: Reset button in Flex
                  Ferrari_hunk

                  Hi Thushar,

                   

                  What you would need to do is, create a function (that will assign the pre load values of every field) and call this function on the click of a custom button that you create. From what it seems, I dont think there is a "reset" button that does this job automatically.

                   

                  Cheers!!