The original title of this blog post was different to begin, but as I was coding I discovered that what I thought was going to be a great tip to share, was in fact not. You see I was trying to do some specialized display in an itemRendererer (in a DataGrid) but was not able to do it. As-is, each row in a particuliar column was displaying an amount, but the requirement came to me to display an amount range based on the value in the next row. For example, say the first row of data was displaying 2.00, and the amount value in the next row was 5.00...the first row should then display 2.00 - 4.99.
I was thinking I could accomplish this by using an itemRenderer and making use of the this.listData.rowIndex property to allow me to "know" the current index in the ArrayCollection, to therefore be able to get the data from the next row, if available. However the rowIndex property gives you the index of the current row being display by the itemRenderer, not the index in the ArrayCollection. Thus my idea backfired.
The reason is, the this.listData.rowIndex property returns the index of the current row being displayed, not the current index of the ArrayCollection as it is being traversed. So if your DataGrid (or any list control for that matter) is only displaying 4 rows, then the rowIndex property will only have values that go from 0 to 3; but your ArrayCollection might have X items in it, so its index will go from 0 to X - 1. And as the user scrolls the list control, although the rowIndex property will always have a range of 0 to 3, the current items from the ArrayCollection that are being displayed, might be items that have index of 14 to 17.
I still don't know how to resolve this issue, if anyone has any ideas, please let me know.