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..



July 23, 2008 at 6:49 am |
Hi,
Could you be so kind as to post the sourcecode.
I’m somewhat new to flex and cannot see where you add the:
mydg.rowCount = mydp.length;
line?
Thanx,
Vichingo
July 23, 2008 at 2:22 pm |
[...] actual post is here and this is the code example of that post.As the viewer [...]
July 23, 2008 at 2:24 pm |
Hi ,
I made a post on that with code you can refer that and its made on 23/July/2008
Comments are welcome.
regards,
kumar.
August 11, 2008 at 8:23 am |
Wat if the data is dynamically imported in the datagrid from mysql , how can i use mydp.length ? As i cant define dataprovider id while importing content in datagrid.
August 11, 2008 at 2:54 pm |
Hi ,
Thats a good question and the answer is simple.
First import the Data into an ArrayCollection and then you assign that to the DataGrid[this can be the dataprovider or specifying the length.] these can be done on result of the HttpService. There are posts on Reading data into ArrayColl from a HttpService can refer that.
regards,
kumar.