Search code examples
flex4advanceddatagrid

AdvancedDatagrid DataTipFunction


i have a grouped AdvancedDatagrid. It looks like...

dataProvider - GroupingCollection2 - Grouping - GroupingField - summaries - summaryRow - fields. Sorry for the strage Codefragemt. I try everything to paste a litte bit mxml-Code. But i fail...

And a AdvancedDataGrid Column with a long long description. I want to show a DataTip. In the grouped headline, the DataTip shows [Object][Object]. In the expanded lines, the DataTip works fine.

I assume, what I need is a DataTipFunction to fix this. In this function, i will receive a object (AdvancedDataGridColumn). But how can i reference to the data of the highlighted line? And how can i find out, if this is a groupedLine or an expanded?

Thank you for reading it Frank


Solution

  • In Adobe Document, it says that the DataTipFunction will look like this:

      private function tipFunc(value:Object):String
      {
          if (value is AdvancedDataGridColumn)
              return "Column Name";
    
          // Use the 'name' property of the data provider element.
          return "Name: " + value["name"];
      }
    

    show the object you received could be an AdvancedDataGridColumn when user's mouse is over the Column Header, and while moving the mouse over a row in datagrid, the function will receive an Object that is the data item in dataProvider.

    when you use grouping, the value item you received will contain a sub-item called 'children', so you can depend on that to determind whether it's an expanded leaf node or grouped node.

    so you function could be:

      private function tipFunc(value:Object):String
      {
          if (value is AdvancedDataGridColumn)
              // return dataTip you want to show for column header
              return "Column Name";
          if(value.hasOwnProperty('children'))
              // return dataTip for grouped column item
              return "Grouped Item";
    
          // return data value in this column
          return value["dataField name"];
      }