3 Replies Latest reply on Nov 3, 2010 9:54 PM by dpark1113

    labelfunction and itemrenderer and xml

    dpark1113 Level 1

      I have a complex xml data that I can only pull the data through datagridcolumn labelfunction.

       

      Such as, <title type="text">Title 123</title>  Output:  Title 123

                    <link content="html" href="http://www.abc.com"/>      Output:  http://www.abc.com

       

      I was only able to pull these data from labelfunction, only problem is I need these data in itemrenderer datagridcolumn.

       

      I've been spending days to figure it out and no solution.

       

      Thanks!

        • 1. Re: labelfunction and itemrenderer and xml
          Flex harUI Adobe Employee

          Not sure I understand the question, but you should be able to call the

          labelFunction from the itemRenderer.  If the itemRenderer implements

          IDropInListItemRenderer then it will have columnIndex information in the

          listData that can be used to reference the column.

          • 2. Re: labelfunction and itemrenderer and xml
            dpark1113 Level 1

            I think you put me on the right track. 

             

            Basically this is what I am doing,

             

            private function labelfunction_handler(item:Object col:DataGridColumn)

            {

             

                 return item.link.(@content == "html").@href;

            }

             

            I want the return data to be access from itemrenderer and assign to <mx:Label>

             

            <mx:DataGrid x="221" y="173">

                 <mx:columns>

                      <mx:DataGridColumn headerText="Column 1" dataField="col1" labelFunction="labelfunction_handler">

                           <mx:itemRenderer>

                                <mx:Component>

                                     <mx:Canvas>

                                          <mx:Label text=""/>

                                     </mx:Canvas>

                                </mx:Component>

                           </mx:itemRenderer>

                      </mx:columns>

            </mx:DataGrid>

             

            Thanks!

            • 3. Re: labelfunction and itemrenderer and xml
              dpark1113 Level 1

              It works, see below

               

              <mx:itemRenderer>

              <fx:Component>

              <mx:Canvas width="100%" creationComplete="init();" implements="mx.controls.listClasses.IDropInListItemRenderer">

              <fx:Script>

              <![CDATA[

              import mx.controls.DataGrid;

              import mx.controls.dataGridClasses.DataGridListData;

              import mx.controls.listClasses.BaseListData;

               

              private var iListData:BaseListData;

              public function get listData():BaseListData

              {

              return iListData;

              }

              public function set listData(value:BaseListData):void

              {

              iListData = value;

              }

              private function init():void

              {

              testlbl.text = DataGridListData(iListData).label;

              }

              ]]>

              </fx:Script>

              <s:Label width="100%" id="testlbl"/>

              </mx:Canvas>

              </fx:Component>

              </mx:itemRenderer>

               

              Thanks!