4 Replies Latest reply on Jul 18, 2006 9:21 PM by jpwrunyan

    is there a way to reference the parent DataGrid from a label function?

    jpwrunyan Level 1
      I am trying to set up some common static labelFunctions for my dataGrids. However, I would still like to be able to know (or reference) the DataGrid instance that is calling the format function. If I remember correctly, you could do this in 1.5 by accessing the item parameter's "_parent" but this doesn't work obviously in 2.0.

      in a typical component where the label function is simply an instance method, I would write like this:

      private function formatItemIndex(item:Object, col:DataGridColumn):String {
      return "item #"+item[col.dataField]+" of "+this.dataProvider.length;

      however, if this becomes a static class function (or utility function), how can I do the same thing?

      private static function formatItemIndex(item:Object, col:DataGridColumn):String {
      //how do I get a ref to the item's DataGrid?

      for now the only work-around I can think of is to put a reference to the DataGrid inside each entry of the DataGrid's dataProvider but this reduces the resuability of the static functions (since I have to decide a specific name for the "source" DG's reference field) and even worse, adds counter-intuitive code and wastes a lot of space in the DG's dataProvider:


      dp = [
      {itemNum: 1, source: this_dg},
      {itemNum: 2, source: this_dg},

      I do not want to write the above form of dataProvider if I can possibly get access to a reference of the DataGrid from item or col.

      If anyone has any suggestions or if this is even possible or not, please let me know.