开发者

Object to arraycollection then to datagrid

开发者 https://www.devze.com 2023-03-06 03:23 出处:网络
Say, linedataColl is an AC that contains 200+ of rows extract from CSV and in my design, I wish to additem into SuperData开发者_运维知识库Collection object by object but the only problem was I\'m unab

Say, linedataColl is an AC that contains 200+ of rows extract from CSV and in my design, I wish to additem into SuperData开发者_运维知识库Collection object by object but the only problem was I'm unable to see any data display in "S" which is a datagrid. What wrong with my code?

var superDataCollection:ArrayCollection = new ArrayCollection();
                    var dc:ArrayCollection = new ArrayCollection();
                    var di:Object = new Object();
                    for(var aa:int=0; aa<5;aa++){
                        di.username = linedataColl[aa].username;
                        di.email = linedataColl[aa].email;
                        dc.addItem(di);
                        superDataCollection.addItem(dc);
                        s.dataProvider = dc;
                    }


Don't set the dataProvider within the for loop. You only need to set it once, and the datagrid will detect changes to the ArrayCollection you specify as a dataProvider.

The best thing to do is set it after you completely build up the ArrayCollection 'dc'.

Perhaps your problem will be fixed by this...

                }
                s.dataProvider = dc;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号