2 Replies Latest reply on Aug 14, 2009 5:26 PM by paul.williams

    Generic item renderer for Adv DG Columns?

    nickmiddleweek

      Hello,

       

      I'm trying to create a generic ItemRenderer for my Adv DG so that so that I can put a toolTip on the cells.

       

      The Adv DG Column object doesn't have a toolTip property so I'm creating my own renderer...

       

      As far as I'm aware I have to create an ItemRenderer that knows the fieldName that it is rendering so I can use {data.myFieldName}. I was hoping there was a property so that I can reference the value generically such as {data.text} but this obvisouly doesn't work...

       

      Is there anyway around this? Can I pass a paramater to the itemRenderer? I'm doing it like this...

       

      advancedDataGridColumn.itemRenderer = new ClassFactory(renderers.ToolTipFieldRenderer);

       


      Alsok, there is a toolTip property of the AdvDG but the columns, what is the AdvDG.toolTip used for? Just a general toolTip? The reason why I need a toolTip is our client has asked to be able to mouse-over the cell to see the full value where the field value is chopped because it's too long for the column...

       

      Hope that makes sense and hope you can help...

       

       

      Cheers,

      Nick

        • 1. Re: Generic item renderer for Adv DG Columns?
          nickmiddleweek Level 1

          Hi,

           

          I've worked out that you can pass data to the ItemRenderer so I can pass it the fieldname as I'm using a ClassFactory...

           

          var toolTipFieldRenderer:ClassFactory = new ClassFactory(renderers.ToolTipFieldRenderer);
          toolTipFieldRenderer.properties = {fieldName: column.columnName};
          advancedDataGridColumn.itemRenderer = toolTipFieldRenderer;

           

          So inside my ItemRenderer I can access the public var/property "fieldName"...

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" verticalScrollPolicy="off" horizontalScrollPolicy="off">
          <mx:Script>
              <![CDATA[
                 
                  public var fieldName:String;
                 
              ]]>
          </mx:Script>
              <mx:Text id="field" text="{data.{fieldName}}" toolTip="{field.text}"  width="100%"/>
          </mx:HBox>

           

           

          But how can I access that value in the text attribute of the Text object?

           

          I'm not far off am I ? :-)

           

           

          Cheers,

          Nick

          • 2. Re: Generic item renderer for Adv DG Columns?
            paul.williams Level 4

            The AdvancedDataGridColumn class has dataTipField and dataTipFunction

            properties and these are supported by the default item renderer

            (AdvancedDataGridItemRenderer), which is also generic. Here's an example:

             

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

            <mx:Application

                xmlns:mx="http://www.adobe.com/2006/mxml"

                layout="absolute">

                

              <mx:Script>

                  <![CDATA[

                     import mx.collections.ArrayCollection;

                              

                    

                     private var dpADG:ArrayCollection = new ArrayCollection([

                       ,

                       ,

                       ,

                       ,

                       ,

                       ,

                       ,

                       ,

                       ,

                       ,

                        

                     ]);                 

                  ]]>

                </mx:Script>

             

                <mx:AdvancedDataGrid

                    height="400"

                    width="300"

                    sortExpertMode="true"

                    dataProvider="">

                    <mx:columns>

                        <mx:AdvancedDataGridColumn

                            dataField="Artist"

                            dataTipField="Artist"

                            showDataTips="true" />

                        <mx:AdvancedDataGridColumn

                            dataField="Album"

                            dataTipField="Album"

                            showDataTips="true" />

                        <mx:AdvancedDataGridColumn

                            dataField="Price"

                            dataTipField="Price"

                            showDataTips="true" />  

                    </mx:columns>

               </mx:AdvancedDataGrid>      

                

            </mx:Application