3 Replies Latest reply on Mar 15, 2012 10:39 PM by Patel Bharat

    Retrieving column number in the datagrid

      Hi ,
      I was trying to retrieve the column number in the datagrid , when we click on the header of the datagrid(on the corresponding column).
      are there any events to retrieve the column number of the column selected .
      I tried using the headerRelease="ClickEvent(event); in the
      <mx:DataGrid id="dg"
      width="100%" height="50" rowHeight="50" editable="true"

      I was able to get the column number using this but
      when the event is called the control is sorting the datagrid column .
      I dont want the datagrid column to be sorted (I tried giving sortable = false , it does'nt help).
      Is there any other way , I could get the data grid column number , when the data grid column header is clicked.


        • 1. Re: Retrieving column number in the datagrid

          Since it is going to sort when you click on the header, you can redirect the sort function:



          • 2. Re: Retrieving column number in the datagrid
            jfb00 Level 3


            Why do you need the column number?

            What are you trying to do?

            • 3. Re: Retrieving column number in the datagrid
              Patel Bharat Level 2



              Try below code. On column header click, will get column number / index:





                            import mx.events.DataGridEvent;


                      import mx.events.ListEvent;

                      private function itemClickEvent(event:DataGridEvent):void {






                  <mx:DataGrid id="myGrid" width="350" height="150"



                          <mx:Object Artist="Pavement" Price="11.99"

                              Album="Slanted and Enchanted" />

                          <mx:Object Artist="Pavement" Album="Brighten the Corners"

                              Price="11.99" />






                      <mx:FormItem label="Column Index:">

                          <mx:Label id="clickColumn"/>               


                      <mx:FormItem label="Type:">

                          <mx:Label id="eventType"/>             






              Enjoy RIA ..