3

I am trying to bind an ArrayCollection result coming in from the server to my DataGrid created dynamically in AS.

The result data is not getting Displayed in the Grid.

var dg:DataGrid = new DataGrid();
dg.width=650; 
dg.dataProvider=someArrayCollfromServer;

I am adding the dgColumn as runtime based on some data from a XML and it is the same as defined in below static format.

But if I use the same code and create the DataGrid as a Flex Component as below, it works fine.

<mx:DataGrid id="dg" width="100%" height="100%" dataProvider="{someArrayCollfromServer}">
<mx:columns>
<mx:DataGridColumn dataField="Value" headerText="Value"/>
<mx:DataGridColumn dataField="Code" headerText="Code" />
</mx:columns>
</mx:DataGrid>

This works fine. Is there some functionality or implementation different as far as DataGrid is concerned in Flex and AS.

Any point of issue here?

1 Answer 1

2

dg.dataProvider=someArrayCollfromServer; just assigns the current value of the variable someArrayCollfromServer (which might be null if it hasn't been populated yet) to the dataProvider. To get data binding, replace that line with:

BindingUtils.bindProperty(dg, "dataProvider", this, "someArrayCollfromServer");

And make sure that someArrayCollfromServer is [Bindable]

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.