标签云

微信群

扫码加入我们

WeChat QR Code

I'm using an AdvancedDataGrid to display hierarchical data. The DataProvider is an object and the children field is an ArrayCollection of objects. When I update one of the objects in the ArrayCollection I'd like the grid to refresh. After researching, I do understand that this won't happen automatically. Not even if I use itemUpdated() and then refresh the AC. Not even if I call executeBindings(recursive). I know that to be smart I should've used ObjectProxy all along as this would solve all my problems. My issue now is how do I go about fixing this without totally revamping my Hierarchical Data objects? I tried having my Value Objects extend ObjectProxy but that didn't do the trick. Is there an elegant solution? Can typed objects even take advantage of ObjectProxy class? Thanks for any helpful tips. Here is the HierarchicalData code:<mx:HierarchicalData source="{model.myObject}"childrenField="trades"/>Here is 'myObject' class:[Bindable]public class MyObject implements ValueObject{public var qty:Number;public var status:String;public var comments:String;public var modified_by:String;public var modified_date:Date;public var trades:ArrayCollection = new ArrayCollection();}The 'trades' ArrayCollection holds a bunch of Trade objects defined here:[Bindable]public class Trade implements ValueObject{public var selected:Boolean = false;public var quantity:Number;public var modified_by:String;public var modified_date:Date;}And here is how I populate the collection after the server returns data:for ( var i:int=0;i<result.length;i++ ){var item:Object = result[i];var recall:MyObject = new MyObject();recall.comments = item.comments;recall.qty= item.qty;recall.status = item.status;recall.modified_by= item.modified_by;recall.modified_date= item.modified_date;recall.trades.addItem( item.trades );model.recalls.addItem( recall );}


1. Have you tried to set your dataSource (HierarchicalData) as Bindable. 2. If you know when your data source is changing anyway why not call myDG.invalidateList() ?

2019年04月18日35分05秒

I've updated the code above to show more specifics. You can see that my dataSource is bindable; the typed classes are bindable. I'm not sure where I could be going wrong here. And yes, I have called invalidateList() in the same place where I tried calling executeBindings(recursive).

1970年01月01日00分03秒

First, is the source of your HierarchicalData really just an object (model.myObject) or is it a mistake and should be model.recalls? Second, when you use typed objects you don't need ObjectProxy. If everything is bindable and you're using ArrayCollection the ADG should update its columns automatically. So, what sort of refresh are you expecting that isn't happening? Can you provide a simple, runnable example?

2019年04月19日35分05秒

Yes, the source of the HierarchicalData is really just one object. The DP is not model.recalls; rather, it is simply 1 object out of that collection. Meaning, there is another ADG and when they click a row a variable gets populated with that object. They get brought to this ADG and the DP becomes that one selected object and its trades. The refresh I'm expecting is that one cell's data gets updated after it is edited. I can debug and see that the value gets updated in the collection but by the time the DG finishes re-rendering, the value is reverted. I'll add a running example a little later.

2019年04月18日35分05秒

That's what I'm doing. I've added my code above so you can see.

2019年04月19日35分05秒