4 Replies Latest reply on Mar 20, 2007 9:40 AM by Gboro54

    data grid font fomating

    Gboro54
      Hi everyone,
      I am trying to write some code that will allow me to set what the font looks like in a data grid. The font is going to chagne when a user chagnes something(i.e the user archives something i want the whole row to be italized based of a certain value that is set). How can this be done, and also in certain situations i only want a certain cell to change(i.e something new was added by another user i only want the first column in that row to be bold) how would that work...

      Thanks
        • 1. Re: data grid font fomating
          Gboro54 Level 1
          opps did not mean to post this three tims sorry,
          • 2. Re: data grid font fomating
            ntsiii Level 3
            That is going to require an itemRenderer.
            Tracy
            • 3. Re: data grid font fomating
              Gboro54 Level 1
              That is what i am trying to do but having trouble with it at this time. I am using an item render in each column but i have a couple questions. One how do i keep the text are from chagein the color of the data grip(i want the colors to stay alternating how they are), two when i wrtie my item renderer, something like this:
              <mx:itemRenderer>
              <mx:Component>
              <mx:TextArea editable="false" fontStyle="italic" />
              </mx:Component>

              </mx:itemRenderer>
              It does not like when i give the text area an id which is not allowing me to change the font in the action script based on a value provided from the xml source...I might be missing something but any more help would be appricated

              Thanks
              • 4. Re: data grid font fomating
                Gboro54 Level 1
                i kinda got it working how i want to now...I am just having one small problem with the following code:
                <mx:DataGridColumn headerText="Name" dataField="@name" >
                <mx:itemRenderer>
                <mx:Component>
                <mx:Text width="100%" text="{data.@name}" creationComplete="fontSet();" >
                <mx:Script>
                <![CDATA[
                public function fontSet():void
                {


                if( data.@value<4)
                {
                this.setStyle("fontSize",12);
                this.setStyle("fontStyle", "italic");
                }
                else this.setStyle("fontSize",10);
                }
                ]]>
                </mx:Script>
                </mx:Text>
                </mx:Component>
                </mx:itemRenderer>
                </mx:DataGridColumn>

                I keep getting the error "Cannot access a property or method of a null object reference", i mean it runs and changes the font but i can not figure why this pops up durning initilaization if anyone knows why please let me know

                Thanks again