5 Replies Latest reply on Nov 1, 2011 10:22 AM by Flex harUI

    Grid change does not broadcast event

    Zolotoj Level 3

      I have the following class

       

      package

          import flash.utils.setTimeout;

         

          import mx.controls.DataGrid;

          import mx.events.DataGridEvent;

         

         

          [Style(name="datagridHeaderDownOverColor",     type="uint")]

          [Style(name="datagridHeaderColor",            type="uint")]

          [Bindable]

          public class DataGridBase extends DataGrid{

              private var _selectedIndex:int = -1;

              public function DataGridBase(){

                  super();

                 

              }

             

       

              protected override function childrenCreated():void

              {

                  this.addEventListener(DataGridEvent.HEADER_RELEASE, onHeaderRelease, false, 0, true);

              }

             

              private function onHeaderRelease(event:DataGridEvent):void

              {

                  if (this.sortableColumns)

                  {

                      setTimeout(scrollToTop, 0);

                  }

              }

             

              private function scrollToTop():void

              {

                  this.scrollToIndex(0);

              }

              override public function get selectedIndex():int

              {

                  return _selectedIndex;

              }

              override public function set selectedIndex(value:int):void

              {

                       trace(value);

                     _selectedIndex = value;

              }

          }

      }

      It looks like when grid is created set selectedIndex is  not called.

      But even if I explicitly set slectedIndex like this:

      grid.selectedIndex = -1 it does not fire whatever event should be fired in order to have data binding that use selectedIndex to work.

      Any idea what I am getting wrong here?

       

      Thanks