2 Replies Latest reply on Jul 27, 2006 11:02 PM by henk_jan

    datagrid labelfunction sort problem

    henk_jan
      I have a problem with sorting on all columns the moment I implement a labelFunction in a datagrid. When I click the datagrid headers nothing happens anymore. I need the labelFunction in the first place to format some data.
      Does anyone has a solution for my problem?

      Here's the code (fragmented):

      ...
      <mx:DataGrid id="dgUsers" dataProvider="{aUsers}">
      <mx:columns>
      <mx:DataGridColumn headerText="number" labelFunction="dispUsers"/>
      <mx:DataGridColumn headerText="name" labelFunction="dispUsers"/>
      <mx:DataGridColumn headerText="role" labelFunction="dispUsers"/>
      </mx:columns>

      </mx:DataGrid>
      ...

      private function dispUsers(item:Object, column: DataGridColumn):String {
      switch(column.headerText) {
      case "number":
      return item.username;

      case "name":
      return formatName(item.voornaam, item.tussenvoegsel, item.achternaam);

      case "role":
      return item.roleName;

      default:
      return "";

      }
      }

      private function formatName(sVoor:String, sMidden:String, sAchter:String):String {
      var sName:String = "";
      if(sAchter != "") {
      sName += sAchter;
      }
      if(sVoor != "") {
      if(sName != "") {
      sName += ", ";
      }
      sName += sVoor;
      }
      if(sMidden != "" && sVoor != "") {
      sName += " " + sMidden;
      }
      return sName;
      }
      ...