5 Replies Latest reply on Feb 8, 2010 10:21 AM by Ansury

    Need TitleWindow close button to just do its thing

    edwinmerced Level 1

      Hello everyone

       

      I have an editable datagrid in a TitleWindow with an enabled close button.


      If I activate the close button with a function, it does not allow me to edit the data grid (and performs its function). How can I just have the close button do its thing (but allowing me to edit my gata grid in the window? It performs the function  if I try to edit the datagrid. Its drivig me a little crazy. So I will take some asprins, and hope for some wise soul to help me

       

      This is the sample code:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Script>
              <![CDATA[
               
              import mx.collections.ArrayCollection;
              import mx.events.DataGridEvent;
             
              [Bindable]
              private var jan:Number = 200;
              private var feb:Number = 123;
              private var mar:Number = 67;
              private var apr:Number = 108;
              private var may:Number = 126;
              private var jun:Number = 199;
              private var jul:Number = 199;
              private var aug:Number = 199;
              private var sep:Number = 199;
              private var oct:Number = 199;
              private var nov:Number = 199;
              private var dec:Number = 199;
              private var dataset:ArrayCollection = new ArrayCollection( [
                  { Month: "January", Data: jan },
                  { Month: "Febuary", Data: feb },
                  { Month: "March", Data: mar },
                  { Month: "April", Data: apr },
                  { Month: "May", Data: may },
                  { Month: "June", Data: jun },
                  { Month: "July", Data: jul },
                  { Month: "August", Data: aug },
                  { Month: "September", Data: sep },
                  { Month: "October", Data: oct },
                  { Month: "November", Data: nov },
                  { Month: "December", Data: dec } ]);
              ]]>
          </mx:Script> 
         
          <mx:ViewStack id="viewstack1" width="464.46967" height="408.18182" horizontalCenter="-12" verticalCenter="0">
              <mx:Canvas id="Data" width="100%" height="100%">
                  <mx:TitleWindow id="DataA" width="450" height="350" layout="absolute" title="Data" horizontalCenter="0" verticalCenter="-10" showCloseButton="true" >
                      <mx:DataGrid x="11" y="10" width="405.98486" height="290" dataProvider="{dataset}" editable="true">
                          <mx:columns>
                              <mx:DataGridColumn width="200" headerText="Month" dataField="Month" editable="false" sortable="false" />
                              <mx:DataGridColumn headerText="Data" dataField="Data" editable="true" sortable="false" />
                          </mx:columns>
                      </mx:DataGrid>
                  </mx:TitleWindow>
                  <mx:Button x="7" y="386" label="Graph" click="viewstack1.selectedChild=Graph;" />
              </mx:Canvas>
              <mx:Canvas id="Graph" width="100%" height="100%">
                  <mx:TitleWindow  id="GraphA" width="450" height="350" layout="absolute" title="Graph" horizontalCenter="0" verticalCenter="-10" showCloseButton="true" click="viewstack1.selectedChild=Data;">
                      <mx:ColumnChart x="8" y="8" id="columnchart1" width="412.12122" height="290" dataProvider="{dataset}">
                                   
                  <mx:horizontalAxis>
                      <mx:CategoryAxis categoryField="Month"/>
                  </mx:horizontalAxis>
                          <mx:series>
                              <mx:ColumnSeries displayName="Series 1" xField="Month" yField="Data"/>
                          </mx:series>
                      </mx:ColumnChart>
                  </mx:TitleWindow>
              </mx:Canvas>
          </mx:ViewStack>
      </mx:Application>

        • 1. Re: Need TitleWindow close button to just do its thing
          Flex harUI Adobe Employee

          I don't think I understand the question.

          • 2. Re: Need TitleWindow close button to just do its thing
            edwinmerced Level 1

            The TitleWindow contains an editable datagrid. If I press anywhere inside the TitleWndow it does not allow me to edit because the close button has a function that moves the stack to graph view. Hope this clarifies

            • 3. Re: Need TitleWindow close button to just do its thing
              Ansury Level 3

              It's still not really clear what you want to do here.  Do you mean you want to be able to click the close (X) button while editing a field in the datagrid, but have the field remain in edit mode?  I ran your example (minus charting components I don't have at home, snowed out of work and Flex Pro at the moment ) and it seems to behave "as I would expect", but maybe I just don't understand what your goal is.

               

              Also - if you're using the close (X) button for anything other than closing a dialog... I wouldn't recommend doing so from a UI design perspective.  Users will expect a 'close' button to behave as it does in other applications, to close the panel/dialog/window (not the change the view within a dialog).  If you intend on using it to back out of a sub-view I'd reconsider.  You may want to try a TabNavigator (lazy man's ViewStack but quite effective if it fits your application) instead of a ViewStack.

              • 4. Re: Need TitleWindow close button to just do its thing
                edwinmerced Level 1

                Helo Ansury:

                 

                Thank you for your enlightening answer. In fact,  I wanted the close button on the Window to flip between the two states (while alowing me to edit the datagrid). It was ipossble for me to achieve this But, you are right in pointing out the UI use of the close button issue-so I may just opt for aother solution. So thank you for bringing up the issue. Do you kow if the close button can be changed for another type of button? Thank you again for your answer

                • 5. Re: Need TitleWindow close button to just do its thing
                  Ansury Level 3

                  You can't replace the close button with anything else (in that exact location) without a crazy hack which wouldn't be worth it, but if you don't want to use a TabNavigator, maybe just add another button next to the one you had at the bottom?

                  1 person found this helpful