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 10 years, 3 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

Pros & Cons of Lightning Component vs. 3rd party frameworks in Salesforce UI development

Video in

Nikita drops by to share his invaluable experience of using popular 3rd party frameworks in Salesforce. http://media.blubrry.com/salesforceway/audio.xmcdn.com/group42/M05/25/57/wKgJ81rXk6XjaZIAAU_I_KtprFM998.m4a