1 Reply Latest reply on Jul 18, 2009 12:15 PM by rockhome6

    Help needed with itemrenderers

    rockhome6

      hey,

       

      I need some help with a couple of things.

       

      1. In one of the columns of an advanced datagrid i need only the text appearing in brackets "( )" to be italicised. The data is fed in from an xml file. I am using the following code but not able to get it to work. Eg: 'abcdex (abcdex) - abcdex' should be shown as 'abcdex (abcdex) - abcdex'

       

           public function returnItalicizedText(inputString:String):String{
               var s1:String="";
               if(inputString.search("(")>=0)
               {
                   s1=inputString.substring(0,inputString.search("(")-2);
                   s1+=" (<i>"+inputString.substring(inputString.search("("),inputString.search(")")-1)+"</i>) ";
                   s1+=inputString.substr(inputString.search(")"),inputString.length-inputString.search(")") +1);
                   return s1;
               }
               else
               return inputString;
           }

       

      I am calling this function using itemrenderers:

       

      <mx:AdvancedDataGridColumn width="230" fontSize="9" headerWordWrap="true" headerText="Product" dataField="Product">
                          <mx:itemRenderer>
                              <mx:Component>
                                  <mx:Label htmlText="{parentDocument.returnItalicizedText(data.Product)}" />
                              </mx:Component>
                          </mx:itemRenderer>

      </mx:AdvancedDataGridColumn>

       

      2. I need the text of a row in a AdvanceddatagridColumn to be bolded depending on a flag passing in the xml input. I am already using itemrenderer and a label component's text property to do some custom formatting to the value. I want to write a condition for the same label's fontweight property so that if the xml tag 'Fixed' == yes then bold the text or else the weight is normal. Here is what i am using:

       

      <mx:AdvancedDataGridColumn fontSize="9" textAlign="center" headerWordWrap="true" headerText="Sale" dataField="Sale">
                          <mx:itemRenderer>
                              <mx:Component>
                                  <mx:Label text="{(Object(data).hasOwnProperty('Sale'))?(parentDocument.nf1.format(String(parseInt(d ata.Sale)/1000))):'-'}"/>
                              </mx:Component>

                          </mx:itemRenderer>
      </mx:AdvancedDataGridColumn>

       

      where nf1 is a number formatter

       

      3. Is there any way i can align the legend items next to the corresponding lines of a linegraph?

       

      Please advice me where am going wrong. Help appreciated.

      Thanks