using split and colors

hi guys
i have a scenario where i will get the following data from backend

Manager: 100
CEO:190
CUSTOMER:900

in my datagrid cell  
if (Manager)
show 100 in the cell and paint the cell as red
if(CEO)
show 190 in the cell and paint the cell as green
if(customer)
show 900 in the cell and paint the cell as yellow

any ideahow i can do that
do i split the strings  and check if ceo or manager or customer?
 

thanks
royjaydAsked:
Who is Participating?
 
dgofmanCommented:
But correct syntax is

var label:String = "Manager: 100";
var pair:Array = label.split(": ");
if(pair.length == 2){
    var title:String = pair[0]; //will give Manager
     var salary:Number = new Number(pair[1]); //will give 100
}
 
0
 
dgofmanCommented:
Use split function

label.split(":");
0
 
royjaydAuthor Commented:
how do i get two seperate strings from Manager: 100 using bel.split(":"); ?
There can be spaces which i would like to trim (space between Manager: and 100 )

thanks
0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
dgofmanCommented:
How about if you will split like bel.split(": "); with the space

any way if you want to trim string here is a syntax

"     Hello_World    ".split(' ').join('');
0
 
royjaydAuthor Commented:
ok but what i want to know is how do i get two seperate strings

should it be
var label:String = "Manager: 100";
var string: name = label.split(":");  //will give Manager
var string: number = label.split(":");  //will give 100

is that correct?

thx

0
 
dgofmanCommented:
no

var label:String = "Manager: 100";
var pair:Array = label.split(": ");
var string: name = pair[0]; //will give Manager
var string: number = pair[1]; //will give 100
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.