This is that the salesforce documentation says about apex:dataTable:

The first element in the iteration visibly rendered in the table, where 0 is the index of the first element in the set of data specified by the value attribute. For example, if you did not want to display the first two elements in the set of records specified by the value attribute, set first="2".

How can I get this elements dynamically (using a variable for example)?


One of the approach, bind variable with controller:

    <apex:page controller="dataTableCon" id="thePage">

    <apex:dataTable value="{!accounts}" var="account" id="theTable" first="{!offset}" styleClass="tableClass">
            <apex:facet name="caption">table caption</apex:facet>

            <apex:facet name="header">table header</apex:facet>

            <apex:facet name="footer">table footer</apex:facet>


                    <apex:facet name="header">Name</apex:facet>

                <apex:facet name="footer">column footer</apex:facet>

                <apex:outputText value="{!account.name}"/>



                <apex:facet name="header">Owner</apex:facet>

                <apex:facet name="footer">column footer</apex:facet>

                <apex:outputText value="{!account.owner.name}"/>



<apex:commndbutton rerender="TheTable" value="Rerender Table" action="{!setOffset}"/>



class dataTableCon {
   public offset {get; set;}
   public void setOffset()
      // doSomething
      offset = "5" // whatever

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.