Activity Forums Salesforce® Discussions Creating a pdf page and want to display row number in first column

  • Creating a pdf page and want to display row number in first column

    Posted by Ajay Prakash on April 14, 2016 at 8:04 am

    Creating a pdf page and want to display row number in first column. I found solution to use apex:variable and increment it.

    <apex:variable value="{!0}" var="index"/>
    <apex:pageBlockTable value="{!salesOrderItems}" var="salesOrderItem" border="1px">
    <apex:variable var="index" value="{!index + 1}"/>
    <apex:column>
    <apex:facet name="header">
    <apex:outputLabel value="Number" />
    </apex:facet>
    <apex:outputLabel value="{!index}" />
    </apex:column>
    </apex:pageBlockTable>

    But in every row '0' is displaying

    Himanshu replied 8 years, 5 months ago 2 Members · 1 Reply
  • 1 Reply
  • Himanshu

    Member
    May 31, 2016 at 9:56 am

    Hi Ajay,

    If you put the counter inside a column, it will work:

    <apex:page controller="counter">
    <apex:variable value="{!0}" var="index" />
    <apex:pageBlock>
    <apex:pageBlockTable value="{!elements}" var="element">
    <apex:column>
    <apex:outputText>
    <apex:variable value="{!index + 1}" var="index" />
    {!index}
    </apex:outputText>
    </apex:column>
    </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:page>

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos