setting dynamically rowCount property in DataGrid control of flex.
Usually we use rowCount property in the DataGrid Tag itself and it specifies the number of rows in the DataGrid.Example is show below..
<mx:DataGrid showHeaders=”false” id=”mydg” x=”80″ y=”52″ useHandCursor=”true” rowCount=”5″>
<mx:columns>
<mx:DataGridColumn headerText=”Name”
dataField=”name”/>
<mx:DataGridColumn headerText=”Age” dataField=”age”/>
</mx:columns>
</mx:DataGrid>
This specifies that the DataGrid rows are 5.
But what if i want to specify this value of the property dynamically ,i.e which depends on the number of rows received from the DB or ArrayCollection, then you can use the following two lines of code..
mydg.rowCount = mydp.length;
where mydp->ArrayCollection.
and iam setting the rowCount to the lenght of ArrayCollection.
So setting the rowCount of the DG dynamically ,simple and small but very usefull..
This snapshot shows that the rowCount=2 which is the length of my ArrayCollection..
