2 Replies Latest reply on Dec 21, 2006 5:06 AM by Mark.P.

    dataGrid / itemRenderer help

      I'm using the itemRenderer example in the help files to convert the background color of a cell depending on the numeric value. That all works just fine but I noticed that on the columns I add that renderer too it makes the cells selectable -- not editable, selectable. When you roll the cursor over any of the columns that don't have the renderer on it, the cursor turns back to an arrow. What do I need to add to the renderer script to make it non selectable and so the arrow cursor is present? I just don't want the user to think they can edit the text in the box.

        • 1. Re: dataGrid / itemRenderer help
          ntsiii Level 3
          First, this is not a Flex Builder question, so it should go in the General Discussion forum, not here.

          Now I'm sort of guessing, because I haven't worked with that example, but it may use a control that is selectable by default. In the renderer, you should be able to do something like this.selectable = false; Maybe in the constructor, or if that doesn't work, in the set data function.

          Let us know.

          • 2. Re: dataGrid / itemRenderer help
            Mark.P. Level 1
            After a few hours of messing around and searching I found an example how to achieve what I was looking for. I used "Label" instead of "TextInput". A Label isn't selectable but the backgroundColor isn't something you can change. So "one way" is to draw in background color, like this -->

            package assets{

            import mx.controls.Label;
            import flash.display.Graphics;

            public class CellColored extends Label {

            override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
            super.updateDisplayList(unscaledWidth, unscaledHeight);
            var g:Graphics = graphics;

            if (this.text != null){
            text = this.text;
            if(Number(text) < 2){
            g.beginFill(0xCC0000);//red - bad
            g.drawRect(0, 0, unscaledWidth, unscaledHeight);
            else if (Number(text) >= 2 && Number(text) < 4){
            g.beginFill(0xF4E002); //yellow - okay
            g.drawRect(0, 0, unscaledWidth, unscaledHeight);
            else if (Number(text) >= 4 && Number(text) <= 6){
            //green - good
            g.drawRect(0, 0, this.unscaledWidth, this.unscaledHeight);
            setStyle("color", 0xFFFFFF);