function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shree KShree K 

Need help..PageBlock button not working to display records on onclick event

Hi
I have a requirement to displays records in pageblock based on "OnClick" event on the pageblock button with render attribute,
That mean when ever the pageblock button is clicked records should be displayed within that pageblock, i am failing to acheive this,
help will be appreciated,

Below is my controller and Vf page code for the reference:

Controller:

public with sharing class DisplayQueryList{ 
public List<Account> Records {get; set;}
public DisplayQueryList(){ 
Records = 
[select Name, AccountNumber, CleanStatus from Account where CleanStatus='Pending']; 

}

VF Page:

<apex:page controller="TestDisplayQueryList">
  <apex:form > 
    <apex:pageBlock title="Tabular display with facet"> 
        <apex:pageBlockTable value="{!Records}" var="Record"> 
            <apex:column > 
                <apex:facet name="header">Account Name</apex:facet> 
                <apex:outputText value="{!Record.Name}"/> 
            </apex:column> 
            <apex:column > 
                <apex:facet name="header">Account Number</apex:facet> 
                <apex:outputText value="{!Record.AccountNumber}"/> 
            </apex:column> 
            <apex:column > 
                <apex:facet name="header">Clean Status</apex:facet> 
                <apex:outputText value="{!Record.CleanStatus}"/> 
            </apex:column> 
        </apex:pageBlockTable> 
    </apex:pageBlock> 
    <apex:pageBlock title="Tabular Display without facet">
    <apex:pageBlockTable value="{!records}" var="record">
        
        <apex:column value="{!record.Name}"/>
        <apex:column value="{!record.AccountNumber}"/>
        <apex:column value="{!record.CleanStatus}"/> 
              
      </apex:pageBlockTable>
    </apex:pageBlock>
   </apex:form>     
</apex:page>
Eswar Prasad@Sfdc11Eswar Prasad@Sfdc11
HI,
 List<Account> Records same variable is using two page block table it won't work. just use it any one.see below  modified code.

<!-----------controller---------------->

public with sharing class DisplayQueryList{ 
public List<Account> Records {get; set;}
public DisplayQueryList(){ 
Records = 
[select Name, AccountNumber, CleanStatus from Account where CleanStatus='Pending']; 

}
<!---pages--------------------------------->
<apex:page controller="TestDisplayQueryList">
  <apex:form > 
    <apex:pageBlock title="Tabular display with facet"> 
        <apex:pageBlockTable value="{!Records}" var="Record"> 
            <apex:column > 
                <apex:facet name="header">Account Name</apex:facet> 
                <apex:outputText value="{!Record.Name}"/> 
            </apex:column> 
            <apex:column > 
                <apex:facet name="header">Account Number</apex:facet> 
                <apex:outputText value="{!Record.AccountNumber}"/> 
            </apex:column> 
            <apex:column > 
                <apex:facet name="header">Clean Status</apex:facet> 
                <apex:outputText value="{!Record.CleanStatus}"/> 
            </apex:column> 
        </apex:pageBlockTable> 
    </apex:pageBlock> 
</apex:form>     
</apex:page>

Regards,
Babaiahgari Eswar 
Shree KShree K

Hi Eswar thanks for the suggestion, but actually i have just pasted in hurry,you could ignore the 2nd page block,for example lets consider only 1st block All i need is 2 pageblock button like when button A clicked records should be displayed when button B clicked records should B hidden preferebly with actionsupport or actionFunction with render attribute.

Thanks
ckrdy 
Balaji BondarBalaji Bondar
Hi CkRdY,

Please try below code:
<apex:commandButton action="{!someAtion}"  reRender="PBTable">
     <apex:param name="con" id="con" value="TRUE"/>
</apex:commandButton>

<apex:commandButton action="{!someAtion}" reRender="PBTable">
     <apex:param name="con" id="con" value="False"/>
</apex:commandButton>

 <apex:pageBlock title="Tabular display with facet" rerendered="{!showPBTable}">
 </apex:pageBlock>

 //Controller
  public boolean showPBTable{get;set;}
 
 public pagereference someAtion(){
 showPBTable = apexpages.currentpage().getparameters().get('con');
 return null;
 }

Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.