0 Replies Latest reply on Aug 10, 2007 9:39 AM by huych02

    Help with DataGrid datatips/tooltips dataTipFunction

    huych02
      The dataProvider for my DataGrid contains a list of ids. I have defined a labelFunction which takes the id and column and fills each column of the DataGrid with the appropriate data.

      Since some of the data is long, I would like a tool tip to display the full data in each cell when the user mouses over it. I have tried using dataTipFunction but it doesn't provide me with a column input to customize it per-cell. Can anyone point me in the right direction for having tool tips that just display the information in the cell the user is mousing over?

      Here is an example of what I'm doing:



      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical">

      <mx:XML id="idList" xmlns="">
      <item id="10">
      <junk/>
      <junk/>
      </item>
      <item id="11">
      <junk/>
      <junk/>
      </item>
      <item id="12">
      <junk/>
      <junk/>
      </item>
      </mx:XML>

      <mx:XML id="pathData" xmlns="">
      <names>
      <name uid="10" label="/Program Files/Adobe/Flex Builder 2/test1"/>
      <name uid="11" label="/Program Files/Adobe/Flex Builder 2/test2"/>
      <name uid="12" label="/Program Files/Adobe/Flex Builder 2/test3"/>
      </names>
      </mx:XML>

      <mx:XML id="permissionData" xmlns="">
      <roles>
      <role uid="10" label="Read Only"/>
      <role uid="11" label="Read/Write"/>
      <role uid="12" label="Read/Write"/>
      </roles>
      </mx:XML>

      <mx:Script>
      <![CDATA[
      private function myLabelFunction(item:Object, column:DataGridColumn):String
      {
      var data:XML;
      switch (column)
      {
      case column1:
      data = pathData.name.(@uid == item.@id)[0];
      return data.@label;
      break;
      case column2:
      data = permissionData.role.(@uid == item.@id)[0];
      return data.@label;
      break;
      }
      return '';
      }

      private function myDataTipFunction(item:Object):String
      {
      return item.toString();

      }
      ]]>
      </mx:Script>

      <mx:Panel width="400" height="300" title="ToolTip Test">
      <mx:DataGrid width="100%" height="100%"
      labelFunction="myLabelFunction"
      dataTipFunction="myDataTipFunction"
      dataProvider="{idList.item}">
      <mx:columns>
      <mx:DataGridColumn id="column1" headerText="Name" showDataTips="true"/>
      <mx:DataGridColumn id="column2" headerText="Role" showDataTips="true"/>
      </mx:columns>
      </mx:DataGrid>
      </mx:Panel>
      </mx:Application>