Why undefined for a number in this datagrid ?
Hi,
Flash CS5
(Keeping this separate to my other thread so as not to sidetrack it too much and assist others with this issue.)
I have a datagrid in which the content is not pulled from an outside source but written in the code just for testing. The grid when clicked on displays in a dynamic text box on stage, (following a youtube article which used Dynamic text) but I get:
BusRoute: Undefined
Sttmnt1: Oxford
Sttmnt2: Burford
Sttmnt3: Swindon
why not the number ? It displays the number as such for each row by the way.
code is:-
import fl.controls.DataGrid;
import flash.events.Event;
import fl.controls.ScrollPolicy;
var item1:Object={BusRoute:"43",Sttmnt1:"Oxford",Sttmnt2:"Burford",Sttmnt3:"Swindon"};
var item2:Object={BusRoute:"361",Sttmnt1:"Evesham",Sttmnt2:"ChippingNorton",Sttmnt3:"Buckingham"};
var myTextFormat:TextFormat=new TextFormat();
myTextFormat.font="Arial";
myTextFormat.color=000000
myTextFormat.size=14;
var datagrid:DataGrid=new DataGrid;
datagrid.move(20,50);
datagrid.width=200;
datagrid.height=70;
datagrid.rowHeight=35;
datagrid.columns=["BusRoute","Sttmnt1","Sttmnt2","Sttmnt3"];
datagrid.columns[0].width=30;
datagrid.columns[1].width=70;
datagrid.columns[2].width=70;
datagrid.resizableColumns=true;
datagrid.horizontalScrollPolicy = ScrollPolicy.ON;
datagrid.setRendererStyle("textFormat",myTextFormat);
datagrid.addItem(item1);
datagrid.addItem(item2);
addChild(datagrid);
datagrid.addEventListener(Event.CHANGE,gridItemClick);
function gridItemClick(event:Event):void{
DataGridSelectedRowText.text="BusRoute:"+event.target.selectedItem.Task + "\n";
DataGridSelectedRowText.appendText("Sttmnt1:"+event.target.selectedItem.Sttmnt1 + "\n");
DataGridSelectedRowText.appendText("Sttmnt2:"+event.target.selectedItem.Sttmnt2 + "\n");
DataGridSelectedRowText.appendText("Sttmnt3:"+event.target.selectedItem.Sttmnt3 + "\n");
}
Envirographics