I have a datagrid whose data provider is an array of the class defined
below:
class MyData
{
public var name : String;
public var percentMarks : Number;
}
When I get this data from the server (through a web service), some of
the "percentMarks" will be null and this is coming up in the datagrid
as NaN. Is there a way to avoide this?
Thanks
Vikram
Just over the top what i can think of is using getters
and setters. This
should do the trick...
class MyData
{
private var _name : String;
private var _percentMarks : Number;
public function set percentMarks(value:Number){
if(value){ _percentMarks = value;}
else { _percentMarks = 0;}
}
public function set name(value:String){
_name = value;
}
public function get percentMarks(){
return _percentMarks;
}
public function get name(){
return _name;
}
}
Its always a best practice to have private properties
in a class and
expose them as getters and setters.
Are you able to display the names properly?? Its only
the numbers which
are causing problems right?
Thanks
Raghu
____________________________________________________________________________________Ready for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.
http://tv.yahoo.com/
Sorry... I forgot the return types for the getters
class MyData
{
private var _name : String;
private var _percentMarks : Number;
public function set
percentMarks(value:Number):void{
if(value){ _percentMarks = value;}
else { _percentMarks = 0;}
}
public function set name(value:String):void{
_name = value;
}
public function get percentMarks():Number{
return _percentMarks;
}
public function get name():String{
return _name;
}
}
Thanks
Raghu
____________________________________________________________________________________Ready
for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.
http://tv.yahoo.com/
____________________________________________________________________________________
Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center.
http://autos.yahoo.com/green_center/
Thanks for the reply. I have no issues with the names.
Having getters and setters for Number wont solve my problem. I cant
have 0 as a default value, as 0 is a valid "percentMarks" for me. I
have to show the actual value, if exists, else show nothing.
Is there a way to achieve this in datagrid?
Thanks
Vikram
On Aug 8, 2:06 pm, Raghunath Rao <raghuonf...@yahoo.com> wrote:
> Hi Vikram,
>
> Sorry... I forgot the return types for the getters
>
> class MyData
> {
> private var _name : String;
> private var _percentMarks : Number;
>
> public function set
> percentMarks(value:Number):void{
> if(value){ _percentMarks = value;}
> else { _percentMarks = 0;}
> }
>
> public function set name(value:String):void{
> _name = value;
> }
>
> public function get percentMarks():Number{
> return _percentMarks;
> }
>
> public function get name():String{
> return _name;
> }
>
> }
>
> Thanks
> Raghu
>
> ____________________________________________________________________________________Ready
> for the edge of your seat?
> Check out tonight's top picks on Yahoo! TV.http://tv.yahoo.com/
>
> ____________________________________________________________________________________
> Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center.http://autos.yahoo.com/green_center/
>
> raghuonflex.vcf
> 1KDownload
Thanks for the reply. I dont have any issues with the name.
I cant have a getter to return a value 0 when teh Number is NaN as 0
is a valid value for me. I want to show nothing in teh datagrid cell
when teh value is NaN. Is there a way to achieve this?
Thanks
Vikram
On Aug 8, 2:06 pm, Raghunath Rao <raghuonf...@yahoo.com> wrote:
> Hi Vikram,
>
> Sorry... I forgot the return types for the getters
>
> class MyData
> {
> private var _name : String;
> private var _percentMarks : Number;
>
> public function set
> percentMarks(value:Number):void{
> if(value){ _percentMarks = value;}
> else { _percentMarks = 0;}
> }
>
> public function set name(value:String):void{
> _name = value;
> }
>
> public function get percentMarks():Number{
> return _percentMarks;
> }
>
> public function get name():String{
> return _name;
> }
>
> }
>
> Thanks
> Raghu
>
> ____________________________________________________________________________________Ready
> for the edge of your seat?
> Check out tonight's top picks on Yahoo! TV.http://tv.yahoo.com/
>
> ____________________________________________________________________________________
> Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center.http://autos.yahoo.com/green_center/
>
> raghuonflex.vcf
> 1KDownload
private var _percentMarks:String; public function set percentMarks(value:String):void{ _percentMarks = value; } public function get percentMarks():String{ return _percentMarks; }
public function set percentMarks(value:Number):void{
if(value){ _percentMarks = value;}
else { _percentMarks = NaN;}
I think its better to use the first method. I'll be interested if
anyone has any other solutions.-- Raghunath Rao Engineer, Flex Framework Adobe Systems, Bangalore --~--~---------~--~----~----------------------~-------~--~ The opinions and views expressed here are purely my own and are in no way endorsed by my company (Adobe Systems) -~----------~----~----~----~------~----~-----------------~
It just struck me... A label function would do the
trick for you.
Sorry for the oversight :)
Raghu
--
Raghunath Rao
Engineer, Flex Framework
Adobe Systems, Bangalore
--~--~---------~--~----~----------------------~-------~--~
The opinions and views expressed here are purely my
own
and are in no way endorsed by my company (Adobe
Systems)
-~----------~----~----~----~------~----~-----------------~
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
On Aug 8, 5:50 pm, Raghunath Rao <raghuonf...@yahoo.com> wrote:
> Hey Vikram,
>
> It just struck me... A label function would do the
> trick for you.
> Sorry for the oversight :)
>
> Raghu
>
> --
>
> Raghunath Rao
> Engineer, Flex Framework
> Adobe Systems, Bangalore
> --~--~---------~--~----~----------------------~-------~--~
> The opinions and views expressed here are purely my
> own
> and are in no way endorsed by my company (Adobe
> Systems)
> -~----------~----~----~----~------~----~-----------------~
>
> ____________________________________________________________________________________
> Yahoo! oneSearch: Finally, mobile search
> that gives answers, not web links.http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
>
> raghuonflex.vcf
> 1KDownload