Solved

Flex ItemRenderer in grid no longer uses datagrid styling.

Posted on 2010-09-20
2
546 Views
Last Modified: 2013-11-11
I have a datagrid with a column that uses an ItemRenderer (Text component since it is multi-lined) to set the font style to italics when the column contains a certain value.  This works fine.  My problem is that the column no longer displays the css styles set for the datagrid.  The rollover color is working, but the textRollOverColor and textSelectedColor are no longer working.  How do I get my Text ItemRenderer to maintain the datagrid styles?  Thanks.
0
Comment
Question by:trudyhlittle
2 Comments
 
LVL 11

Accepted Solution

by:
petiex earned 250 total points
Comment Utility
I think the problem is that the mx.controls.Text component does not have a textRollOverColor or textSelectedColor style.

To simulate the textRollOverColor style in the renderer, you could add event listeners to the mouseOver and mouseOut events to change the Text control's style["color"] to the roll-over color and back to the default color, respectively. Then for the textSelectedColor, you could change the text color on the focusIn and focusOut events of the dataGridColumn.

OR, I think you could just extend the default DataGridItemRenderer, override the set data function to conditionally set the style to italic using something like the attached code, and then, to allow for multi-line text, just set variableRowHeight="true" on the DataGrid, and set wordWrap="true" on the DataGridColumn.
package testflex {
import mx.controls.dataGridClasses.DataGridItemRenderer;

public class TestRenderer extends DataGridItemRenderer {
    public function TestRenderer() {
        super();
    }
    public override function set data(data:Object):void{
        if(data["clam"]=="try"){// set the field value where you want to italicize
            setStyle("fontStyle", "italic");
        }
        super.data = data;
    }
}
}

Open in new window

0
 

Author Closing Comment

by:trudyhlittle
Comment Utility
Thanks a bunch.  I tried using the MouseOver and MouseOut events originally.  This worked if the user was actually over the data column itself, however, if they were hovering over another column when the were selected a row, the rollovers weren't displayed.  Extending the DataGridItemRenderer worked and with a lot less coding.  Thanks.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now