0
“stab”是一个tabnavigator,我喜欢在navigatorcontent中访问datagrid中的id。我试过getchildbyname
不能,它似乎无法找到datagrid“nc1,nc2等”,并返回null。在navigatorcontent中获取id
private var pdg:String="nc";
private function stabAdd():void {
var dg1:DataGrid = new DataGrid();
var cn:NavigatorContent = new NavigatorContent();
stab.addElement(cn);
cn.label = "New Tab";
cn.name = "nct"+nu;
cn.id = "nct"+nu;
dg1.id = "nc"+nu;
dg1.name = "nc"+nu;
pdg = dg1.id; //set this as current datagrid
nu++;
var columns:Array = [];
var myDataGridColumn:DataGridColumn = new DataGridColumn("id");
myDataGridColumn.headerText = "ID";
myDataGridColumn.width = 40;
columns.push(myDataGridColumn);
myDataGridColumn = new DataGridColumn("username");
myDataGridColumn.headerText = "Name";
myDataGridColumn.width = 160;
.....
dg1.columns = columns;
cn.addElement(dg1);
stab.selectedIndex = stab.numChildren-1;
}
我不喜欢'getChildByName()' - 尝试使用'container [“nc1”]'等等。 – Marty 2011-05-10 04:16:09
我可以获得“容器”教程吗?我们似乎不知道。 – Jonyang 2011-05-10 04:59:13
容器 - > ** DataGrid的父**。 – Marty 2011-05-10 05:05:12