That worked Jason, and much cleaner too.  Thanks!  I knew that it 
was just a syntax combination that I hadn't seen yet. ()[] - who 
knew?  Only one change: I moved the default rowColor back up above 
the rowColors loop, to avoid overwriting.  I've been chewing (let's 
say festering) on this for more than a week now.  After I add some 
bells and whistles, I'll post the sample.  From the number of 
related questions, hopefully this is an example that might benefit 
others.  I'll make sure to give you proper credit.

Thanks again,
Tim

--- In [email protected], "Pan Troglodytes" 
<[EMAIL PROTECTED]> wrote:
>
> Okay, no problem.  I think you're going to want to replace your 
for loop
> with this:
> 
> for (rc = rowColors.length-1; rc >= 0; rc--) // loop backwards for 
priority
> order
> {
>     rowColorCriteria.dataField = StyleManager.getStyleDeclaration
> ("."+rowColors[rc]).getStyle("dataField");
>     rowColorCriteria.condition = StyleManager.getStyleDeclaration
> ("."+rowColors[rc]).getStyle("condition");
>     rowColorCriteria.value = StyleManager.getStyleDeclaration
> ("."+rowColors[rc]).getStyle("value");
>     rowColorCriteria.backgroundColor = StyleManager.getColorName(
> StyleManager.getStyleDeclaration("."+rowColors[rc]).getStyle
("backgroundColor"));
> 
> 
>     if (actualRow < dataProvider.length)
>     {
>         currentCellData = dataProvider.getItemAt(actualRow)[
> rowColorCriteria.dataField];
> 
>         switch (rowColorCriteria.condition.toLowerCase())
>         {
>             case "eq" :
>                 if (currentCellData == rowColorCriteria.value) 
rowColorValue
> = rowColorCriteria.backgroundColor;
>                     break;
>             case "ne" :
>                 if (currentCellData != rowColorCriteria.value) 
rowColorValue
> = rowColorCriteria.backgroundColor;
>                 break;
>                 case "lt" :
>                 if (currentCellData < rowColorCriteria.value) 
rowColorValue
> = rowColorCriteria.backgroundColor;
>                     break;
>              case "gt" :
>                     if (currentCellData > rowColorCriteria.value)
> rowColorValue = rowColorCriteria.backgroundColor;
>                  break;
>                 case "lteq" :
>                     if (currentCellData <= rowColorCriteria.value)
> rowColorValue = rowColorCriteria.backgroundColor;
>                     break;
>                 case "gteq" :
>                     if (currentCellData >= rowColorCriteria.value)
> rowColorValue = rowColorCriteria.backgroundColor;
>                     break;
>                 default :
>                     rowColorValue = colors[actualRow % 
colors.length];
>                     break;
> 
>         } // condition && value
>     }
> } // rowColors
> 
> 
> On 7/25/06, Tim Hoff <[EMAIL PROTECTED]> wrote:
> >
> > Here's the example.  Right click to view/download code.  Look at
> > RowColorDataGrid.as component, near the bottom.
> >
> > 
http://www.iepl.net/DataGridRowColorSample/DataGridRowColorSample.htm
l
> >
> > -TH
> >
> > --- In [email protected], "Pan Troglodytes" 
<chimpathetic@>
> > wrote:
> > >
> > > I don't understand why that would fail. What is actualRow? Is 
it the
> > last
> > > parameter passed into drawRowBackground()? That's what you 
should be
> > > using. If that's what it is, can you post a small example that
> > reproduces
> > > you problem?
> > >
> > > I'm using the method Matt posting and it's working great. So 
there must
> > be
> > > some small detail throwing things off.
> > >
> > > On 7/25/06, Tim Hoff TimHoff@ wrote:
> > > >
> > > > Jason,
> > > >
> > > > Thanks for the response. If I was using an ArrayCollection 
outside
> > > > of the subclassed DataGrid component, that makes sense. 
However,
> > > > inside the component, I'm not having any luck accessing the
> > > > dataProvider and/or underlying data with any method. I tried 
the
> > > > following line, but it comes up blank.
> > > >
> > > > rowData = dataProvider.getItemAt(actualRow,0);
> > > >
> > > > Again, it may just be something that I'm doing wrong through
> > > > subclassing; like setter/getter or something similar.
> > > >
> > > > -TH
> > > >
> > > > --- In [email protected], "Pan Troglodytes"
> > > > chimpathetic@ wrote:
> > > > >
> > > > > Matt just means to use getItemAt(dataIndex) to get the 
item for
> > > > row. Then
> > > > > you can use whatever field/property to make your decision 
on how
> > > > to color
> > > > > it. Make sense?
> > > > >
> > > > > On 7/25/06, Tim Hoff TimHoff@ wrote:
> > > > > >
> > > > > > Matt, or anyone else,
> > > > > >
> > > > > > Similar to your suggestion, I've been creating a sample 
that
> > > > shows how to
> > > > > > set the row color of a DataGrid. When you say, "get data 
at
> > > > dataIndex
> > > > > > using dataProvider methods", how exactly do you go about 
this.
> > > > Manish
> > > > > > suggested looking at the iterator. I've tried this, as 
well as
> > > > listData,
> > > > > > dataProvider and several others. The problem is that 
none of
> > > > them are
> > > > > > returning the actual data in individual cells. I'm sure 
that my
> > > > thick head
> > > > > > is just missing something simple. The following sample 
shows
> > > > where I'm at
> > > > > > with this currently. If you have any tips or advise that 
can
> > > > help me get
> > > > > > over this hurdle, I would greatly appreciate it. This 
won't be
> > > > a component
> > > > > > for sale, but rather a sample for free.
> > > > > >
> > > > > >
> > > > 
DataGridRowColorSample<http://www.iepl.net/DataGridRowColorSample/Dat
> > > > aGridRowColorSample.html>
> > > > > > - See RowColorDataGrid.as near the bottom.
> > > > > >
> > > > > > Thanks,
> > > > > > Tim Hoff
> > > > > >
> > > > > >
> > > > > > --- In [email protected], "Matt Chotin" 
<mchotin@>
> > > > wrote:
> > > > > > >
> > > > > > > For dealing with the row backgrounds maybe you could 
look into
> > > > > > > subclassing DataGrid and overriding drawRowBackground?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > override protected function drawRowBackground(s:Sprite
> > > > > > >
> > > > 
<http://livedocs.macromedia.com/flex/2/langref/flash/display/Sprite.h
> > > > tml
> > > > > > > > , rowIndex:int
> > > > > > > 
<http://livedocs.macromedia.com/flex/2/langref/int.html> ,
> > > > y:Number
> > > > > > > 
<http://livedocs.macromedia.com/flex/2/langref/Number.html> ,
> > > > > > > height:Number
> > > > > > > 
<http://livedocs.macromedia.com/flex/2/langref/Number.html> ,
> > > > color:uint
> > > > > > > 
<http://livedocs.macromedia.com/flex/2/langref/uint.html> ,
> > > > > > > dataIndex:int
> > > > <http://livedocs.macromedia.com/flex/2/langref/int.html>
> > > > > > > ):void
> > > > > > >
> > > > 
<http://livedocs.macromedia.com/flex/2/langref/specialTypes.html#void
> > > > >
> > > > > >
> > > > > > >
> > > > > > > {
> > > > > > >
> > > > > > > //get data at dataIndex using dataProvider methods
> > > > > > >
> > > > > > > //var colorToUse:uint = dataIsSpecial ? customColor : 
color;
> > > > > > >
> > > > > > > Super.drawRowBackground(s, rowIndex, y, height, 
colorToUse,
> > > > dataIndex);
> > > > > > >
> > > > > > > }
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > That could eliminate a lot of the extra renderers?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Matt
> > > > > > >
> > > > > > > ________________________________
> > > > > > >
> > > > > > > From: [email protected]
> > > > [mailto:[EMAIL PROTECTED] On
> > > > > > > Behalf Of Pan Troglodytes
> > > > > > > Sent: Friday, July 21, 2006 7:42 AM
> > > > > > > To: [email protected]
> > > > > > > Subject: Re: [flexcoders] performance issues
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Yeah, I've tried that. Here's the the actual full code 
I'm
> > > > using:
> > > > > > >
> > > > > > > override public function set data(value:Object):void {
> > > > > > > var dirty:Boolean = (value != null) && (data != value);
> > > > > > > super.data = value;
> > > > > > >
> > > > > > > if (dirty) {
> > > > > > > var n:Number = data[DataGridListData
(listData).dataField];
> > > > > > > if (n < 0)
> > > > > > > setStyle("color", negativeColor);
> > > > > > > else if (n > 0)
> > > > > > > setStyle("color", positiveColor);
> > > > > > > else if (n == 0)
> > > > > > > setStyle("color", zeroColor);
> > > > > > > }
> > > > > > > }
> > > > > > >
> > > > > > > As I mentioned before, the main slowness is not just 
scrolling
> > > > a row at
> > > > > > > a time but whole pages. The hit is coming in when it 
has to
> > > > set the
> > > > > > > data on every itemRenderer onscreen at once. This 
usually
> > > > happens when
> > > > > > > scrolling by quickly dragging the scroll thumb.
> > > > > > >
> > > > > > > And yes, there are a lot of records on-screen. 
Probably about
> > > > 45. If I
> > > > > > > shrink it, performance gets better. It's probably also 
hurting
> > > > that all
> > > > > > > eight columns have to be itemRenderers, because I need 
to
> > > > color the row
> > > > > > > background on a per-row basis depending on the data. 
Only one
> > > > of the
> > > > > > > rows are something other than simple text. What I 
think might
> > > > help the
> > > > > > > most is to build a smarter datagrid that knows how to 
do some
> > > > events at
> > > > > > > the grid level ( e.g. set the styling of each cell 
depending
> > > > on the
> > > > > > > data) rather than forcing anything other than plain 
text
> > > > that's the same
> > > > > > > on every row to use a custom renderer.
> > > > > > >
> > > > > > > As for ben's reply, I believe it fires every time any 
row
> > > > scrolls into
> > > > > > > and out of view is because it reuses renderers, 
setting the
> > > > data instead
> > > > > > > of creating a whole new renderer. When you scroll 
down, the
> > > > top row
> > > > > > > gets reused as the new bottom row. Found this out when 
I didn't
> > > > > > > properly invalidate my colored backgrounds.
> > > > > > >
> > > > > > > On 7/21/06, Matt Chotin mchotin@ wrote:
> > > > > > >
> > > > > > > Well DataGrid scrolling performance is something that 
we've
> > > > spent a lot
> > > > > > > of time tuning so I would love for us to get a full 
test case
> > > > that we
> > > > > > > can look at. I saw in the thread you linked mentioning 
a
> > > > 1600x1200
> > > > > > > monitor, is the DataGrid taking up most of that real 
estate?
> > > > The more
> > > > > > > visible rows the slower the scrolling will be. Another 
thing
> > > > you could
> > > > > > > look at is in your setter for the data comparing 
against the
> > > > old value
> > > > > > > and if it hasn't changed not doing anything, it may be 
that
> > > > it's
> > > > > > > invalidating too often? I'll ask one of the people who 
worked
> > > > on
> > > > > > > performance if she has any thoughts.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Matt
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > ________________________________
> > > > > > >
> > > > > > > From: [email protected]
> > > > [mailto:[email protected] ] On
> > > > > > > Behalf Of Pan Troglodytes
> > > > > > > Sent: Wednesday, July 19, 2006 11:44 PM
> > > > > > > To: [email protected]
> > > > > > > Subject: [flexcoders] performance issues
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Well, specifically I had a DataGrid using this for the
> > > > itemRenderer:
> > > > > > >
> > > > > > > package nes {
> > > > > > >
> > > > > > > import mx.controls.dataGridClasses.DataGridListData ;
> > > > > > > import mx.controls.Label;
> > > > > > >
> > > > > > > public class SignColorItemRenderer extends Label {
> > > > > > > public var negativeColor:uint = 0xFF0000;
> > > > > > > public var positiveColor:uint = 0x008000;
> > > > > > > public var zeroColor:uint;
> > > > > > >
> > > > > > > override public function set data(value:Object):void {
> > > > > > > super.data = value;
> > > > > > >
> > > > > > > var n:Number = data[DataGridListData
(listData).dataField];
> > > > > > > if (n < 0)
> > > > > > > setStyle("color", negativeColor);
> > > > > > > else if (n > 0)
> > > > > > > setStyle("color", positiveColor);
> > > > > > > else if (n == 0)
> > > > > > > setStyle("color", zeroColor);
> > > > > > > }
> > > > > > > }
> > > > > > > }
> > > > > > >
> > > > > > > I brought it up in this thread:
> > > > > > >
> > > > 
http://groups.yahoo.com/group/flexcoders/message/43243;_ylc=X3oDMTM3c
> > > > WM2
> > > > > > >
> > > > 
MG9mBF9TAzk3MzU5NzE0BGdycElkAzEyMjg2MTY3BGdycHNwSWQDMTYwMDAwNzIwNwRtc
> > > > 2dJ
> > > > > > >
> > > > 
ZAM0MzI2MwRzZWMDZnRyBHNsawN2dHBjBHN0aW1lAzExNTI4NTY4NDUEdHBjSWQDNDMyN
> > > > DM-
> > > > > > >
> > > > > > > I tried LOADS of different ways to do it. I found that 
anytime
> > > > I put
> > > > > > > much of any extra code in, it took away from the
> > > > responsiveness. Even
> > > > > > > replacing the above data procedure with just a single 
setStyle
> > > > > > > statement. As I said, it's not horrible. But I 
definitely
> > > > notice it.
> > > > > > >
> > > > > > > The other main thing I can point out is some 
sluggishness when
> > > > resizing
> > > > > > > the browser window and having it resize/relayout the 
Flex app.
> > > > But it's
> > > > > > > hard to tell how much of that is the browser and how 
much is
> > > > Flex.
> > > > > > >
> > > > > > > On 7/20/06, Matt Chotin < mchotin@ <mailto:mchotin@ >
> > > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > > Can you provide a little more detail on the 
performance areas
> > > > that are
> > > > > > > hurting you? If there's a sample that demonstrates the 
speed
> > > > issue it
> > > > > > > may be something we can look at.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Matt
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > ________________________________
> > > > > > >
> > > > > > > From: [email protected] [mailto:
> > > > [email protected]
> > > > > > > <mailto:[email protected] ] On Behalf Of Pan
> > > > Troglodytes
> > > > > > > Sent: Wednesday, July 19, 2006 10:49 PM
> > > > > > > To: [email protected]
> > > > > > > Subject: Re: [flexcoders] So? What are folks here 
actually
> > > > building...?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Well, since I have never programmed in ActionScript at 
all, my
> > > > projects
> > > > > > > have served a dual purpose - functional and 
educational. In
> > > > other
> > > > > > > words, some of the software may never see the light of 
day but
> > > > that's
> > > > > > > okay - at least it taught me how to build in Flex.
> > > > > > >
> > > > > > > My most "real" application has been an ad-hoc query 
builder.
> > > > We have
> > > > > > > some financial reporting that it broken down into 
various
> > > > fields:
> > > > > > > branch, quarter, period, that kind of thing. So I gave 
each
> > > > field an
> > > > > > > accordion pane and filled it with the values for that 
field.
> > > > Then I let
> > > > > > > the user drag-n-drop the values for each field into 
another
> > > > List,
> > > > > > > arranging them hierarchically however they want. This 
then
> > > > feeds a sql
> > > > > > > statement that uses group by and rollup to get all the 
data
> > > > both on the
> > > > > > > detail level and summarized by each parent level.
> > > > > > >
> > > > > > > I then feed that into a DataGrid that has many custom
> > > > renderers. The
> > > > > > > main powerhouse is the "tree" renderer. Basically, the 
first
> > > > column
> > > > > > > down the page looks like a tree of those key fields. 
So if
> > > > they chose
> > > > > > > to report by quarter, then branch, then manager, it 
would look
> > > > like:
> > > > > > >
> > > > > > > (view the following in a fixed width font)
> > > > > > > Gross Expenses Profit
> > > > > > > Total X X X
> > > > > > > 1Q-2006 X X X
> > > > > > > Branch 1 X X X
> > > > > > > Jane Doe X X X
> > > > > > > John Smith X X X
> > > > > > > Branch 2 X X X
> > > > > > > Phil Johnson X X X
> > > > > > > 2Q-2006 X X X
> > > > > > > Branch 1 X X X
> > > > > > > Jane Doe X X X
> > > > > > > John Smith X X X
> > > > > > > Branch 2 X X X
> > > > > > > Phil Johnson X X X
> > > > > > >
> > > > > > > I put in Xs because I got tired of making up stuff. 
But you
> > > > get the
> > > > > > > picture. It's basically very pivot-table-ish. It's 
really the
> > > > > > > graphical touches that seal the deal. There's icons and
> > > > animations and
> > > > > > > colors all over the place. Not too much, but more than 
I could
> > > > have
> > > > > > > coded in the week or so I've been building it. I'm an
> > > > experienced
> > > > > > > Delphi user and have to say I'm really blown away by 
Flex.
> > > > Delphi is
> > > > > > > RAD but Flex is RAD^2.
> > > > > > >
> > > > > > > Okay, for my VERY basic advice on what I would put 
some effort
> > > > into.
> > > > > > > Well, first, fix the bugs that have come out here. You 
have a
> > > > pretty
> > > > > > > wide base of components already and I would like them 
to be
> > > > very stable.
> > > > > > > Nothing slows a developer down more than spending 
hours on a
> > > > problem to
> > > > > > > only find the bug isn't in his/her code.
> > > > > > >
> > > > > > > Second, I would REALLY like to see some optimization 
done. I
> > > > know this
> > > > > > > is going to be hard with the dynamic, frequently 
untyped
> > > > nature of Flex.
> > > > > > > But some of the code runs painfully slow for what it 
does. I'm
> > > > still
> > > > > > > not 100% happy with the speed of those custom 
itemRenderers in
> > > > the grid.
> > > > > > > And I stripped them down as far as they can go and 
it's not
> > > > because I
> > > > > > > wrote bad code. Overall, the speed is good for 
an "internet
> > > > > > > application". Internet apps get to make excuses. But 
I'd like
> > > > to get
> > > > > > > the speed good enough to rival native desktop apps. 
Sure, not
> > > > on
> > > > > > > everything - but at least on GUI graphics.
> > > > > > >
> > > > > > > Keep up the good work. I haven't had this much fun 
with a new
> > > > language
> > > > > > > in a while...
> > > > > > >
> > > > > > > On 7/20/06, David Mendels < dmendels@
> > > > > >
> > > > > > > <mailto:dmendels@ > wrote:
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Hello,
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > It has been less than a month since we shipped Flex, 
but I
> > > > know many
> > > > > > > folks on this list had projects they started back in 
the
> > > > public beta
> > > > > > > time. I know in many cases you may not be able to talk 
about
> > > > what
> > > > > > > projects you are working on, but for those who can I'd 
love to
> > > > get a
> > > > > > > view onto what folks are building. We spent a long time
> > > > (almost two
> > > > > > > years) on all the parts of the Flex 2 product line 
(and the
> > > > Flash Player
> > > > > > > 9) and it is very cool to see the traffic here, the 
emergence
> > > > of third
> > > > > > > party conferences like www.flexseminar.com , the books 
coming
> > > > out on
> > > > > > > Flex, the 60K plus downloads of the IDE in the public 
beta,
> > > > but we'd
> > > > > > > love to get a sense of what real applications people 
are
> > > > starting to
> > > > > > > build. The team is already working on plans for mid-
term and
> > > > longer
> > > > > > > term upgrades to Flex, and it helps us to really 
understand
> > > > what people
> > > > > > > are building. So, if you are able to talk about what 
you are
> > > > building
> > > > > > > please do share--I think it would be very interesting 
for the
> > > > community
> > > > > > > and very valuable for us on the Flex team at Adobe.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --David
> > > > > > >
> > > > > > > Adobe
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Jason
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Jason
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Jason
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Jason
> > > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Flexcoders Mailing List
> > > > FAQ: 
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > > Search Archives:
> > http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > > > Yahoo! Groups Links
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > Jason
> > >
> >
> > 
> >
> 
> 
> 
> -- 
> Jason
>







------------------------ Yahoo! Groups Sponsor --------------------~--> 
Check out the new improvements in Yahoo! Groups email.
http://us.click.yahoo.com/7EuRwD/fOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to