header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
flex
Points:0
Posts:0

5/25/2010 10:48:59 PM

Title: programmatic itemRenderer to datagrid column


Hi,

I have advanced datagrid which im creating dynamically in actionscript....each time the column of datagrid will be different...

Now im using itemrenderer to columns to display values of columns in different colors.. but my problem now is,each column is having different rules(conditions) to give colors...

Like..column 1--- >50 red, <100 green , else black
column 2---->200 red , <1000 green ,else black..


Since column varies each time , condition also varies... and i dont want to use item renderer for eack grid column differently... is there any way to do it more dynamically? like by passing column name and condition in item renderer?

If yes please suggest me the solution...please provide me some good code as im new to this..


oColumnDef.itemRenderer=new customColorComponent();


public class customColorComponent extends Label implements IFactory
{

public function customColorComponent()
{
super();
}
override public function set data(value:Object):void
{
if(AdvancedDataGridListData(listData).dataField=='value1')
{
if(value != null)
{
super.data = value;
if(value[AdvancedDataGridListData(listData).dataField] < 100) {
setStyle("color", 0xFF0000);
}

}
}
}



but if i do like this for each column i have to write code..but dont want like that...pls suggest me any way of passing column name and rules to itemrenderer class..pls its urgent..

Thanks in advance:)



1
Connor
Points: 0
Posts:0
5/26/2010 6:13:25 AM



I think you are taking about the rows and not the columns, Am i right ?

2
Austin
Points: 0
Posts:0
5/26/2010 10:51:21 AM



you want to make the rows color different in datagrid depending upon the count, like upto 50 rows red and then 50-100 green etc. i think to do this you can extend the datagrid class and add your custom functionality like this. Let me know if this is the functionality required, I may try it.

3
flex
Points: 0
Posts:0
5/26/2010 9:14:30 PM



Hi,Austin....
Thanks for considering my quesion..But the functionalitity is not as u told...

I have datagrid like..

col1 col2 col3
12 5 100
16 6 200
56 10 1020
45 20 56
100 50 234


this datagrid i have created in actionscript and each time number of columns in datagrid may varie....

I want col1 values less than 20 should display in red and other in green...
In col2 value less tha 10 display in red and other in green..
In col3 value less 1000 in red and other in green...

How to achive this..

switch(oColumnDef.dataField)
{
case "@col1":
oColumnDef.visible=true;
oColumnDef.itemRenderer=new customColorComponent();
break;
case "@col2":
oColumnDef.visible=true;
oColumnDef.itemRenderer=new customColorComponent();
break
}


im using itemrenderer for each column separatly..is there any way to use single itemrenderer for all columns?

Im really bugged because of this..pls help me....


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 4+4 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions