2 Replies Latest reply on Jul 25, 2011 5:44 AM by j@i

    error during tooltip on datagrid

    j@i

      hi everyone,

       

      I'm trying to get tooltip on datagrid mouse over item with item data in it.But its generating some runtime error.its given here in bold

       

      Argument count mismatch on DataGrid_ToolTip/buildDataTip(). Expected 1, got 2.

       

      colud any one plz help on it.

       

      thankyou,

       

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

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

         xmlns:s="library://ns.adobe.com/flex/spark"

         xmlns:mx="library://ns.adobe.com/flex/mx"

         creationComplete="application2_creationCompleteHandler(event)">

      <fx:Script>

      <![CDATA[

      import mx.collections.ArrayCollection;

      import mx.events.FlexEvent;

      import mx.rpc.events.ResultEvent;

       

      [Bindable]

      public var empArray:ArrayCollection =new ArrayCollection();

       

      /* protected function empData_resultHandler(event:ResultEvent):void

      {

      empArray = event.result.data.employee;

       

      } */

       

      protected function application2_creationCompleteHandler(event:FlexEvent):void

      {

      empArray.addItem({name:"Srini",exp:"1",degination:"Software Engineer"});

       

      empArray.addItem({name:"Afzal",exp:"1",degination:"Software Engineer"});

       

      empArray.addItem({name:"Nag",exp:"1",degination:"Software Engineer"});

       

      }

      public function buildDataTip(item:Object):String

      {

      var myString:String = "";

       

      if(item != null)

      {

      myString = myString+ "Name : "+item.name;

      myString = myString+ "Experience : "+item.exp+"/n";

      myString = myString+ "designation : "+item.degination+"/n";

      }

      return myString;

      }

       

      ]]>

      </fx:Script>

      <fx:Declarations>

      <!-- Place non-visual elements (e.g., services, value objects) here -->

      <!--<s:HTTPService id="empData" url="data/data1.xml" result="empData_resultHandler(event)"/>-->

      </fx:Declarations>

       

      <s:VGroup width="100%" height="100%" verticalAlign="middle" horizontalAlign="center">

      <s:DataGrid id="empDetails" dataProvider="{empArray}" requestedRowCount="10" width="50%"

      dataTipFunction="buildDataTip">

      <s:columns>

      <s:ArrayList>

      <s:GridColumn dataField="name" headerText="Name" showDataTips="true"/>

      <s:GridColumn dataField="exp" headerText="Experience" showDataTips="true"/>

      <s:GridColumn dataField="degination" headerText="Designation" showDataTips="true"/>

      </s:ArrayList>

      </s:columns>

      </s:DataGrid>

       

      </s:VGroup>

       

      </s:Application>

        • 1. Re: error during tooltip on datagrid
          Pooja Kuber

          Add one more parameter in the buidDataTip function, since

           

          the signature of the dataTipFunction function for Spark data grid is as follows:

           

          dataTipFunction(item:Object, column:GridColumn):String

           

          public function buildDataTip(item:Object,column:GridColumn):String

          {

          var myString:String = "";

           

          if(item != null)

          {

          myString = myString+ "Name : "+item.name;

          myString = myString+ "Experience : "+item.exp+"/n";

          myString = myString+ "designation : "+item.degination+"/n";

          }

          return myString;

          }

          Thanks and Regards,
          ..................................................................... ......................
          Pooja Kuber | pkuber@infocepts.com | www.infocepts.com

          ...................................................................... .....................

          • 2. Re: error during tooltip on datagrid
            j@i Level 1

            hi pooja,

             

            thanks alot,its working.