apex:PageBlockTable in Visualforce


This post Describing about using apex:pageblocktable and apex:column.

--- Visual Force --

<apex:page controller="listpractice" sidebar="false" >
 <apex:form >
     <apex:pageBlock title="List">
         <apex:pageBlockSection >
               <apex:pageBlockTable value="{!allrecords}" var="rec" width="1200px">
             
                  <apex:column title="sdgsdgsd" headerValue="Form Ids" >
                      {!rec.id}
                  </apex:column>
                  <apex:column headerValue="Name" >
                       {!rec.name}
                  </apex:column>

               </apex:pageBlockTable>
        </apex:pageBlockSection>
     </apex:pageBlock>
 </apex:form>
</apex:page>

--- Controllers --

public class listpractice {

    public List<Account> allrecords { get; set; }

    public List<Account> getAllrecords() {
        return null;
    }
   
    public listpractice()
    {
    allrecords=[select id,name from account Limit 20 Offset 2];
    // limit is used to display only 20 records here
    // offset wont dispaly first two records
    }
}

Comments

Popular posts from this blog

Community/Experience Cloud Interview Questions

Script to delete multiple records using Apex salesforce

Change Owner / Update record using Lightning Custom Button Salesforce