У меня проблема с классами модели моего advancedDataGrid. Вот мои классы моделей:Flex AdvancedDataGrid с IHierarchical Objects
package module.testPlanModule
{
import flash.events.Event;
import flash.utils.IDataInput;
import flash.utils.IDataOutput;
import flash.utils.IExternalizable;
import mx.collections.IHierarchicalData;
import mx.utils.UIDUtil;
[Bindable]
[RemoteClass(alias="business.project.version.testPlan.TestSuite")]
public class TestSuite implements IExternalizable, IHierarchicalData
{
private var _uuid:String;
private var _ID:String;
private var _testCasesList:Array;
public function TestSuite()
{
_uuid = UIDUtil.createUID();
_ID = "TESTSUITE-"+Math.random();
_testCasesList = [];
}
public function get testCasesList():Array
{
return _testCasesList;
}
public function set testCasesList(value:Array):void
{
_testCasesList = value;
}
public function get ID():String
{
return _ID;
}
public function set ID(value:String):void
{
_ID = value;
}
public function get uuid():String
{
return _uuid;
}
public function set uuid(value:String):void
{
_uuid = value;
}
public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void
{
// TODO Auto Generated method stub
}
public function dispatchEvent(event:Event):Boolean
{
// TODO Auto Generated method stub
return false;
}
public function hasEventListener(type:String):Boolean
{
// TODO Auto Generated method stub
return false;
}
public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void
{
// TODO Auto Generated method stub
}
public function willTrigger(type:String):Boolean
{
// TODO Auto Generated method stub
return false;
}
public function canHaveChildren(node:Object):Boolean
{
if(node is TestSuite){
return true;
}
else if(node is TestCase){
return true;
}
else
return false;
}
public function hasChildren(node:Object):Boolean
{
if(node is TestSuite){
return !(node.testCasesList.length == 0);
}
else if(node is TestCase){
return !(node.allocatedTests.length == 0);
}
else
return false;
}
public function getChildren(node:Object):Object
{
if(node is TestSuite){
return node.testCasesList;
}
else if(node is TestCase){
return node.allocatedTests;
}
else
return null;
}
public function getData(node:Object):Object
{
return node;
}
public function getRoot():Object
{
// TODO Auto Generated method stub
return null;
}
public function writeExternal(output:IDataOutput):void
{
output.writeUTF(_uuid);
output.writeUTF(_ID);
output.writeObject(_testCasesList);
}
public function readExternal(input:IDataInput):void
{
_uuid = input.readUTF();
_ID = input.readUTF();
_testCasesList = input.readObject();
}
}
}
package module.testPlanModule
{
import flash.events.Event;
import flash.utils.IDataInput;
import flash.utils.IDataOutput;
import flash.utils.IExternalizable;
import mx.collections.IHierarchicalData;
import mx.utils.UIDUtil;
[Bindable]
[RemoteClass(alias="business.project.version.testPlan.TestCase")]
public class TestCase implements IExternalizable, IHierarchicalData
{
private var _uuid:String;
private var _ID:String;
private var _allocatedTests:Array;
public function TestCase()
{
_uuid = UIDUtil.createUID();
_ID = "TESTCASE-"+Math.random();
_allocatedTests = [];
}
public function get ID():String
{
return _ID;
}
public function set ID(value:String):void
{
_ID = value;
}
public function get allocatedTests():Array
{
return _allocatedTests;
}
public function set allocatedTests(value:Array):void
{
_allocatedTests = value;
}
public function get uuid():String
{
return _uuid;
}
public function set uuid(value:String):void
{
_uuid = value;
}
public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void
{
// TODO Auto Generated method stub
}
public function dispatchEvent(event:Event):Boolean
{
// TODO Auto Generated method stub
return false;
}
public function hasEventListener(type:String):Boolean
{
// TODO Auto Generated method stub
return false;
}
public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void
{
// TODO Auto Generated method stub
}
public function willTrigger(type:String):Boolean
{
// TODO Auto Generated method stub
return false;
}
public function canHaveChildren(node:Object):Boolean
{
if(node is TestSuite){
return true;
}
else if(node is TestCase){
return true;
}
else
return false;
}
public function hasChildren(node:Object):Boolean
{
if(node is TestSuite){
return !(node.testCasesList.length == 0);
}
else if(node is TestCase){
return !(node.allocatedTests.length == 0);
}
else
return false;
}
public function getChildren(node:Object):Object
{
if(node is TestSuite){
return node.testCasesList;
}
else if(node is TestCase){
return node.allocatedTests;
}
else
return null;
}
public function getData(node:Object):Object
{
return node;
}
public function getRoot():Object
{
// TODO Auto Generated method stub
return null;
}
public function writeExternal(output:IDataOutput):void
{
output.writeUTF(_uuid);
output.writeUTF(_ID);
output.writeObject(_allocatedTests);
}
public function readExternal(input:IDataInput):void
{
_uuid = input.readUTF();
_ID = input.readUTF();
_allocatedTests = input.readObject();
}
}
}
package module.testPlanModule
{
import flash.events.Event;
import flash.utils.IDataInput;
import flash.utils.IDataOutput;
import flash.utils.IExternalizable;
import mx.collections.IHierarchicalData;
import mx.utils.UIDUtil;
[Bindable]
[RemoteClass(alias="business.project.version.test.TestBase")]
public class TestBase implements IExternalizable, IHierarchicalData
{
private var _uuid:String;
private var _ID:String;
private var _state:String;
private var _result:String;
private var _allocatedUser:String;
private var _linkedRequirements:Array;
public function TestBase()
{
_uuid = UIDUtil.createUID();
_ID = "TEST-"+Math.random();
_state = "not passed";
_result = "na";
_allocatedUser = "";
_linkedRequirements = [];
}
public function get ID():String
{
return _ID;
}
public function set ID(value:String):void
{
_ID = value;
}
public function get state():String
{
return _state;
}
public function set state(value:String):void
{
_state = value;
}
public function get result():String
{
return _result;
}
public function set result(value:String):void
{
_result = value;
}
public function get allocatedUser():String
{
return _allocatedUser;
}
public function set allocatedUser(value:String):void
{
_allocatedUser = value;
}
public function get linkedRequirements():Array
{
return _linkedRequirements;
}
public function set linkedRequirements(value:Array):void
{
_linkedRequirements = value;
}
public function get uuid():String
{
return _uuid;
}
public function set uuid(value:String):void
{
_uuid = value;
}
public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void
{
// TODO Auto Generated method stub
}
public function dispatchEvent(event:Event):Boolean
{
// TODO Auto Generated method stub
return false;
}
public function hasEventListener(type:String):Boolean
{
// TODO Auto Generated method stub
return false;
}
public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void
{
// TODO Auto Generated method stub
}
public function willTrigger(type:String):Boolean
{
// TODO Auto Generated method stub
return false;
}
public function canHaveChildren(node:Object):Boolean
{
if(node is TestSuite){
return true;
}
else if(node is TestCase){
return true;
}
else
return false;
}
public function hasChildren(node:Object):Boolean
{
if(node is TestSuite){
return !(node.testCasesList.length == 0);
}
else if(node is TestCase){
return !(node.allocatedTests.length == 0);
}
else
return false;
}
public function getChildren(node:Object):Object
{
if(node is TestSuite){
return node.testCasesList;
}
else if(node is TestCase){
return node.allocatedTests;
}
else
return null;
}
public function getData(node:Object):Object
{
return node;
}
public function getRoot():Object
{
// TODO Auto Generated method stub
return null;
}
public function writeExternal(output:IDataOutput):void
{
output.writeUTF(_uuid);
output.writeUTF(_ID);
output.writeUTF(_state);
output.writeUTF(_result);
output.writeUTF(_allocatedUser);
output.writeObject(_linkedRequirements);
}
public function readExternal(input:IDataInput):void
{
_uuid = input.readUTF();
_ID = input.readUTF();
_state = input.readUTF();
_result = input.readUTF();
_allocatedUser = input.readUTF();
_linkedRequirements = input.readObject();
}
}
}
А вот мой AdvancedDataGrid:
<mx:AdvancedDataGrid id="testPlanADG" displayItemsExpanded="true"
width="95%" height="95%"
contentBackgroundAlpha="0.0" chromeColor="0xdbeaff"
openDuration="500"
verticalScrollPolicy="on"
horizontalScrollPolicy="auto"
variableRowHeight="true">
<mx:columns>
<mx:AdvancedDataGridColumn id="IdCol" dataField="ID" headerText="ID"
/>
<mx:AdvancedDataGridColumn dataField="state" headerText="State"/>
<mx:AdvancedDataGridColumn dataField="result" headerText="Result"/>
<mx:AdvancedDataGridColumn dataField="allocatedUser" headerText="User affected"/>
</mx:columns>
</mx:AdvancedDataGrid>
Проблема заключается в том, что только идентификатор Тестов никогда отображаются и ничего другого. Для заполнения ADG я сделал это:
_model = new ArrayCollection();
// here I populate the model
var testSuite1:TestSuite = new TestSuite();
testSuite1.ID = "testSuite1";
var testCase1:TestCase = new TestCase();
testCase1.ID = "testCase1";
var testBase1:TestBase = new TestBase();
testBase1.ID = "testBase1";
var testBase2:TestBase = new TestBase();
testBase2.ID = "testBase2";
testCase1.allocatedTests = [testBase1,testBase2];
// ...
_testPlanHierarchy = new HierarchicalData();
_testPlanHierarchy.source = _model;
testPlanADG.dataProvider = _testPlanHierarchy;
Я могу видеть ID моих двух тестовых наборов отображается как лист узлы и ничего другого. Я действительно не понимаю.
Я заменил все массивы на ArrayCollections и переименовал их в «детей», и теперь он отлично работает. Большое спасибо! – TheFrenchGuy