0 Replies Latest reply on Oct 2, 2009 7:28 AM by flexDv

    HeaderRenderer refresh Issue-Please help

    flexDv

      hi

      I have a datagrid and I am  doing a custom sorting on the grid(by getting data from DB).

      I achieve this by capturing the headerrelease event of datagrid .In thee venthandler I will query from DB and do event.preventdefault to prevent standard grid sorting.

      Now I need to display my own custom ascending/descending arrows in the header.i have created an header renderer for this,

      In the headerrenderer I am lsitening to the headerrelease event of datagrid and in the eventlistener, as per the sortfield, i am trying to make the sort arrow visible/invisible.

      But somehow making the sort arrows visible/invisible is not working.The initial arrow works fine.it is shown the correct column(Name) as done in the init() method.

      The eventhandler is invoked on clicking the column headers and all the alerts are shown.

      Please see the headerrenderer code below and help me.(code is not complete only the relevant part is included)

       

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:HBox

      xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" horizontalScrollPolicy="off" creationComplete="init()" implements="mx.controls.listClasses.IDropInListItemRenderer">
       

      public function init():void
      {


      headerLabel = dataField.label;


      _dataGrid.addEventListener(DataGridEvent.HEADER_RELEASE,sortChanged,false);

      if(_dataField.localeCompare('Name')==0)asc.visible=true;
      }


      private function sortChanged(e:DataGridEvent)
      {


      var dg:DataGrid=e.currentTarget asDataGrid;

      varcolumn:DataGridColumn = DataGridColumn(e.currentTarget.columns[e.columnIndex]);
      if(_dataField.localeCompare(e.dataField)==0)
      {

      if(asc.visible ||(!asc.visible&&!desc.visible))

      {

        Alert.show('in..');
        asc.visible=false;
        desc.visible=true;
      }

      else if(desc.visible)
      {
        asc.visible=true;
        desc.visible=false;
      }

      }

      else

      {

      asc.visible=false;
      desc.visible=false;


      }

      }

      ]]>

      </mx:Script>

      <mx:Text text="{_headerLabel}" />

      <mx:Image source="{ascIcon}" id='asc' visible="false">

      <mx:Image source="{descIcon}" id='desc' visible="false"/>

      </mx:HBox>