+ Start a Discussion
JimmyMacJimmyMac 

Ability to look ahead 1 row from within <apex:repeat> loop..

Hi, I need to perform some page break logic, and would like to be able to look at the NEXT row from within a repeat loop to determine if the value is about to change.

For the display logic I can't check AFTER the next row is read, I need to check the NEXT row's value while processing the CURRENT row.

 

So is there some way to access the relatedHoldings2[row + 1] while I am processing the current row in the loop?

 

Thanks!

 

 

<apex:repeat var="fa" value="{!relatedHoldings2}">  
Compare relatedHoldings2.val from row #2 with relatedHoldings2.val from current row
</apex>

 var="fa" value="{!relatedHoldings2}">

bob_buzzardbob_buzzard
You won't be able to do this in the page I'm afraid. The way I'd handle it is to back the apex:repeat with a wrapper class (which you might be - I don't know your controller) and have a flag in the wrapper class instance to show whether the next value in the list is different.
JimmyMacJimmyMac

I actually found a way...

 

I created an apex:variable, and used it as a rowct, then I used it as an index to access the rowct + 1 row:

 

For example:

 

Whie in my apex:Repeat

 myrowt = myrowct + 1 (apex:variable)

finacct[myrowct + 1].myfield (the NEXT rows value)

 

Thanks.