在数据完整性方面,我认为将一个带有子节点的对象作为ArrayCollection就可以了。那么为什么我的AdvancedDataGrid renderProvider会渲染每个子节点呢?我只是不明白。 (我的renderProvider是一个DataGrid)。这会为每个新项目生成一个新的数据网格。
我希望我不必重写我的数据结构。
以下是代码:
recalls.addItem(
new ObjectProxy(
{
selected:false,
id:1001,
cpty:'MERRILLINTL',
ticker:'PG:IT',
secId:'7743621',
origQty:8150,
currQty:8150,
rebate:-5.25,
div:100,
dueDate:'7/1/2011',
status:'New',
comments:'',
children:new ArrayCollection( [
{
sid:96548714,
type:'BVRI',
secType:'COMMON',
ticker:'PG:IT',
cpty:'MERRILLINTL',
cusip:'T8380H120',
sedol:'7743621',
rate:-5.25,
qty:20000,
recallQty:20000
},
{
sid:23544165,
type:'BVRI',
secType:'COMMON',
ticker:'PG:IT',
cpty:'MERRILLINTL',
cusip:'T8380H120',
sedol:'7743621',
rate:-5.25,
qty:5000,
recallQty:5000
}
]),
trades:new ArrayCollection([
{
sid:12211214,
type:'BVRI',
secType:'COMMON',
ticker:'PG:IT',
cpty:'MERRILLINTL',
cusip:'T8380H120',
sedol:'7743621',
rate:-5.25,
qty:1700,
recallQty:1700
},
{
sid:32112256,
type:'BVRI',
secType:'COMMON',
ticker:'PG:IT',
cpty:'MERRILLINTL',
cusip:'T8380H120',
sedol:'7743621',
rate:-5.25,
qty:6450,
recallQty:6450
}
])
}
)
);
recalls.addItem(
new ObjectProxy(
{
selected:false,
id:1002,
cpty:'GSAL',
ticker:'TH:CA',
secId:'82934H101',
origQty:5400,
currQty:5400,
rebate:-2,
div:100,
dueDate:'8/9/2011',
status:'New',
comments:'',
children:new ArrayCollection([
{
sid:32555688,
type:'BVRI',
secType:'COMMON',
ticker:'TH:CA',
cpty:'GSAL',
cusip:'88338H100',
sedol:2889906,
rate:-2,
qty:7500,
recallQty:7500
},
{
sid:65487745,
type:'BVRI',
secType:'COMMON',
ticker:'TH:CA',
cpty:'GSAL',
cusip:'88338H100',
sedol:2889906,
rate:-2,
qty:3500,
recallQty:3500
}
]),
trades:new ArrayCollection([
{
sid:14445784,
type:'BVRI',
secType:'COMMON',
ticker:'TH:CA',
cpty:'GSAL',
cusip:'88338H100',
sedol:2889906,
rate:-2,
qty:3200,
recallQty:3200
},
{
sid:96552544,
type:'BVRI',
secType:'COMMON',
ticker:'TH:CA',
cpty:'GSAL',
cusip:'88338H100',
sedol:2889906,
rate:-2,
qty:2200,
recallQty:2200
}
])
}
)
);
上面的arraycollection是我的AdvancedDataGrid的dataProvider。这是ADG的DP。
<mx:dataProvider>
<mx:HierarchicalData
source="{recalls}"/>
</mx:dataProvider>
以下是此ADG的renderProvider的代码:
<mx:rendererProviders>
<mx:AdvancedDataGridRendererProvider
depth="2"
columnIndex="1"
renderer="com.controls.GroupedTradesGrid"
columnSpan="0"/>
</mx:rendererProviders>
在这个renderProvider中,我使用这段代码来设置DP:
override public function set data(value:Object):void
{
// If using the array data source, use this instead:
dataProvider = value;
// adjust rowCount
this.rowCount = dataProvider.length + 1;
}
基本上,正在为'children'集合中的每个元素创建一个新的DataGrid ...而不是创建一个datagrid,并填充'children'集合。这是为什么?
感谢您提供任何有用的提示!
答案 0 :(得分:0)
我不知道你在做什么,但你的dataProvider应该是一个ArrayCollection而不是一个对象。
dataProvider = "{ObjectProxy.children}"
答案 1 :(得分:0)
我找到了解决这个问题的方法,但我不认为这是正确的解决办法;但是,它现在必须要做。我猜我使用了错误的语法并将'children'属性括在括号中,我会很好:就像这样:
children:[new ArrayCollection( [
{
sid:96548714,
type:'BVRI',
secType:'COMMON',
ticker:'PG:IT',
cpty:'MERRILLINTL',
cusip:'T8380H120',
sedol:'7743621',
rate:-5.25,
qty:20000,
recallQty:20000
},
{
sid:23544165,
type:'BVRI',
secType:'COMMON',
ticker:'PG:IT',
cpty:'MERRILLINTL',
cusip:'T8380H120',
sedol:'7743621',
rate:-5.25,
qty:5000,
recallQty:5000
}
])]