function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mmixmmix 

Detect first/last row in repeater?

How can I detect one without having to write a wrapper class carrying such indicator?

 

In general, how do you create JSON array using visualforce in regards to the ommission of last comma? For example, I currently use this approach:

 

<apex:page standardController="Case" extensions="extension_Timeline" contentType="text/javascript" showHeader="false" sidebar="false">
{ "data" : [ 
	<apex:repeat value="{!allItems}" var="item">
		<apex:outputText value="," rendered="{!NOT(item.firstItem)}" />
		{
			"Type": "{!item.ItemType}",
			"dateTime": "{!item.DateTime}",
			"userName": "{!item.UserName}",
			"content": "{!JSENCODE(item.Content)}",
			"FullContent": "{!JSENCODE(item.FullContent)}"
		}
	</apex:repeat>
]}

</apex:page>

 however, this approach forces me to "repack" the SOQL List<SObject> into List<MyCustomWrapperWithFirstRowIndicator> which is a pain and wastes resources. Any other approach I might be missing?