5 Replies Latest reply on Aug 19, 2011 10:04 AM by Don Kerr

    spark Datagrid columnheader click

    USchmitt Level 1

      Hello!

       

      With the following Eventlistener i can detect a click on the Spark Datagrid-Header.

       

      dg.sortableColumns = false;
      dg.columnHeaderGroup.addEventListener(MouseEvent.CLICK, headerClickListener);
      ……………..
      //Header click event handler
      private function headerClickListener(event:MouseEvent):void {
      Alert.show(“Do Something”);

       

      But how can I detect the current column of the clicked Headeritem?

       

      In my Opinion a Build-In Header-click-event and a Build-In Columnlocking is a "Must Have" of a professional Datagrid.

       

      Will there be a Flexupdate with an enhanced Spark Datagrid in the next time?

       

      Greetings

       

      Uwe

        • 1. Re: spark Datagrid columnheader click
          kevinklin Adobe Employee

          Listen for the GridEvent.GRID_CLICK event instead. The GridEvent will have the column index in it. We redispatch all mouse events on the DataGrid as GridEvents.

           

          -Kevin

          • 2. Re: spark Datagrid columnheader click
            USchmitt Level 1

            You are right!

             

            I thougt that GRID_Click works only on cells and not on the headers.

             

            Thanks for your quick help!

             

            Uwe

            • 3. Re: spark Datagrid columnheader click
              Don Kerr Level 3

              Kevin, on a related topic.  I've "change" event on grids/lists in the past.  That appears to have gone away with spark dataGrid.

               

              What is the best way to select a row? what is the difference between selectionChange and GridClick?

               

              Don

              • 4. Re: spark Datagrid columnheader click
                kevinklin Adobe Employee

                Do you mean programmatically selecting a row? or detecting when a user has just selected a row?

                 

                If the first, there are a bunch of selection API's available on DataGrid. I'd take a look at the documentation and let me know if you have further questions.

                 

                If the second, selectionChange is dispatched whenever the selection is changed via user interaction (mouse click, key stroke, etc...). The gridClick event is dispatched only when a mouse click happens in the DataGrid, no relation to the selection changing.

                 

                Hope that helps.

                 

                -Kevin

                • 5. Re: spark Datagrid columnheader click
                  Don Kerr Level 3

                  Just trying to sort out in my head which one to use when the user clicks/taps a row to select it, not programmatically.  Both selectionChange and gridClick fire when the user clicks/taps in the Grid and they both set the selectedItem property, so it is just a little gray which one to use.

                   

                  I'll did deeper into the docs on GridEvent vs. GridSelectionEvent, but not sure the use case for each one.

                   

                  Yes, there are a bunch of selection APIs, which only begs the question: which make the most sense to use when.  I was more curious at this point.

                   

                  Appreciate the help.

                   

                  Don