Monday 4 November 2013

Example to Display Page block Table on button click

<apex:page controller="showpgbtable" >
 <apex:form >
  <apex:commandButton value="showtable" action="{!accountlist}" reRender="panel"/>
   <apex:outputPanel id="panel" >
    <apex:pageBlock rendered="{!rendered}" >
     <apex:pageBlockTable value="{!accounts}" var="a" >
      <apex:column value="{!a.name}"/>
     </apex:pageBlockTable>
    </apex:pageBlock>
   </apex:outputPanel>
 </apex:form>
</apex:page>

//controller class
public class showpgbtable {
 public list<Account> acc1 = new list<account>();
public Boolean rendered{set;get;}
public showpgbtable(){ //constructor
rendered =false;
}
 public pageReference Accountlist(){
    acc1 = [select id,name from account ];
     rendered  = true;
    return null;
   }
   public list<account> getaccounts(){
   return acc1;
   }
Screen Shots:-

}

No comments:

Post a Comment