簡體   English   中英

我的分層數據結構不能作為數據提供者

[英]My hierarchical datastructure isn'tworking as a dataprovider

在數據完整性方面,我認為將一個對象及其子對象作為 ArrayCollection 就好了。 那么為什么我的 AdvancedDataGrid renderProvider 會渲染每個子節點呢? 我只是不明白。 (我的 renderProvider 是一個 DataGrid )。 這會為每個新項目生成一個新的數據網格。

我希望我不必重寫我的數據結構。

這是代碼:

recalls.addItem( 
                new ObjectProxy(
                    {
                        dueDate:'7/1/2011',
                        status:'New',
                        comments:'',
                        children:new ArrayCollection( [
                            {
                                rate:-5.25,
                                qty:20000,
                                recallQty:20000
                            },
                            {
                                rate:-5.25,
                                qty:5000,
                                recallQty:5000
                            }
                        ]),
                        items:new ArrayCollection([
                            {
                                rate:-5.25,
                                qty:1700,
                                recallQty:1700
                            },
                            {
                                rate:-5.25,
                                qty:6450,
                                recallQty:6450
                            }
                        ])
                    }
                )
            );
            recalls.addItem( 
                new ObjectProxy(
                    {
                        selected:false,
                        id:1002,
                        rebate:-2,
                        div:100,
                        dueDate:'8/9/2011',
                        status:'New',
                        comments:'',
                        children:new ArrayCollection([
                            {
                                sid:32555688,
                                rate:-2,
                                qty:7500,
                                recallQty:7500
                            },
                            {
                                rate:-2,
                                qty:3500,
                                recallQty:3500
                            }
                        ]),
                        items:new ArrayCollection([
                            {
                                rate:-2,
                                qty:3200,
                                recallQty:3200
                            },
                            {
                                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;
        }

基本上,正在為“子”集合中的每個元素創建一個新的數據網格……而不是創建一個數據網格並填充它的“子”集合。 這是為什么?

感謝您提供任何有用的提示!

不確定我明白你在做什么,但你的 dataProvider 應該是一個 ArrayCollection 而不是一個對象。

dataProvider = "{ObjectProxy.children}"

我已經找到解決方法,但是我認為這不是正確的解決方案。 但是,現在必須這樣做。 我猜我使用了錯誤的語法,並將'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
                        }
                    ])]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM