You need to sign in to do that
Don't have an account?
Lukasz Piziak
PageBlockTable - Populating filtered records?
Hi All,
Is there a way of populating a list of records in the PageBlockTable Section based on a filter criteria? Basically I have a records with different production status value. Let say I have 20 records with status = open and 45 records with status value = complete,
I woudl like to dispaly records with satus open only.
Thank you for any suggestions and help.
Below is my code for my table:
<apex:page standardController="SCMC__Production_Order__c" sidebar="false" showheader="false" recordSetVar="SCMC__Production_Order__c">
<apex:form >
<apex:pageBlock rendered="True" title="Production Orders">
<apex:pageBlockSection title="Production Orders to Fill">
<apex:pageBlockTable value="{!SCMC__Production_Order__c}" style="width:1220px" var="item">
<apex:column style="width:100px" headerValue="Production Order No." value="{!item.name}" />
<apex:column style="width:100px" value="{!item.Sales_Order_No__c}"/>
<apex:column style="width:100px" value="{!item.Customer__c}" headerValue="Customer Name"/>
<apex:column style="width:200px" value="{!item.Assembly_Name__c}" headerValue="Hose Description"/>
<apex:column style="width:150px" value="{!item.SCMC__Start_Date__c}" headerValue="Production Start Date"/>
<apex:column style="width:150px" value="{!item.SCMC__Planned_Completion_Date__c}" headerValue="Planned Completion Date"/>
<apex:column style="width:150px" value="{!item.SCMC__Production_Status__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Is there a way of populating a list of records in the PageBlockTable Section based on a filter criteria? Basically I have a records with different production status value. Let say I have 20 records with status = open and 45 records with status value = complete,
I woudl like to dispaly records with satus open only.
Thank you for any suggestions and help.
Below is my code for my table:
<apex:page standardController="SCMC__Production_Order__c" sidebar="false" showheader="false" recordSetVar="SCMC__Production_Order__c">
<apex:form >
<apex:pageBlock rendered="True" title="Production Orders">
<apex:pageBlockSection title="Production Orders to Fill">
<apex:pageBlockTable value="{!SCMC__Production_Order__c}" style="width:1220px" var="item">
<apex:column style="width:100px" headerValue="Production Order No." value="{!item.name}" />
<apex:column style="width:100px" value="{!item.Sales_Order_No__c}"/>
<apex:column style="width:100px" value="{!item.Customer__c}" headerValue="Customer Name"/>
<apex:column style="width:200px" value="{!item.Assembly_Name__c}" headerValue="Hose Description"/>
<apex:column style="width:150px" value="{!item.SCMC__Start_Date__c}" headerValue="Production Start Date"/>
<apex:column style="width:150px" value="{!item.SCMC__Planned_Completion_Date__c}" headerValue="Planned Completion Date"/>
<apex:column style="width:150px" value="{!item.SCMC__Production_Status__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
You are better off creating an extension class like "TestExtension", use SOQL to query you object with the filter applies in the where clause and passing the filterd list of SCMC__Production_Order__c back to be render in your visual force page.
change your Page in 2 places see underline/bold.
Add class Save and run.
Thx.
All Answers
1. Use rendered="{!IF(item.Status__c = 'Open', true, false)}" in each of your column like
<apex:column rendered="{!IF(item.Status__c = 'Open', true, false)}" style="width:100px" headerValue="Production Order No." value="{!item.name}" />
2. If it does not break any other logic in comtroller then filter the records in Apex itself when you are fetching them
Thanks
Shashikant
Thank you for your quick reply. I have used your first option and I think This will not work for me as the records with other status are still displayed.
Could you please explain to me of how I can filter the Apex itself?
Shashikant,
Please see below print screen before I have used render IF code
Here is after
You need to use rerendered attribute in each column you declared. Here is the code,
Thanks
Prosenjit
You are better off creating an extension class like "TestExtension", use SOQL to query you object with the filter applies in the where clause and passing the filterd list of SCMC__Production_Order__c back to be render in your visual force page.
change your Page in 2 places see underline/bold.
Add class Save and run.
Thx.
so basicall add this: extensions = "TestExtension"
and change to this: value="{!objlist}"
thx
Thank you for your help. This is exactly what I want!!!
Is working for me now and it is filtering based on Class you have provided.
Could you please advise if I can use more than one extension in one VP? In my case I have a page with 2 page BlockTables.
One is displaying all records with 'Open' status and second table I wish to display all records with 'complete' status.
Please find below code a full version of the code I have used for this page:
<apex:page standardController="SCMC__Production_Order__c" sidebar="false" showheader="true" recordSetVar="SCMC__Production_Order__c" extensions="TestExtension">
<apex:form >
<apex:pageBlock rendered="True" title="Production Orders">
<apex:pageBlockSection title="Production Orders to Fill">
<apex:pageBlockTable value="{!objlist}" style="width:1220px" var="item">
<apex:column style="width:100px" headerValue="Production Order No." value="{!item.name}" />
<apex:column style="width:100px" value="{!item.Sales_Order_No__c}"/>
<apex:column style="width:100px" value="{!item.Customer__c}" headerValue="Customer Name"/>
<apex:column style="width:200px" value="{!item.Assembly_Name__c}" headerValue="Hose Description"/>
<apex:column style="width:150px" value="{!item.SCMC__Start_Date__c}" headerValue="Production Start Date"/>
<apex:column style="width:150px" value="{!item.SCMC__Planned_Completion_Date__c}" headerValue="Planned Completion Date"/>
<apex:column style="width:150px" value="{!item.SCMC__Production_Status__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection title="Production Order in Progress">
<apex:pageBlockTable value="{!SCMC__Production_Order__c}" style="width:1220px" var="item">
<apex:column style="width:100px" value="{!item.name}" headerValue="Production Order No."/>
<apex:column style="width:100px" value="{!item.Sales_Order_No__c}"/>
<apex:column style="width:100px" value="{!item.Customer__c}" headerValue="Customer Name"/>
<apex:column style="width:200px" value="{!item.Assembly_Name__c}" headerValue="Hose Description"/>
<apex:column style="width:150px" value="{!item.Hose_Assembly_By__c}" headerValue="Technician"/>
<apex:column style="width:150px" value="{!item.SCMC__Planned_Completion_Date__c}" headerValue="Planned Completion Date"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Now after adding another extension class to my VP my tables displaying records based on two dfferent filter settings.
Below is full code and classess.
Visual Page:
<apex:page standardController="SCMC__Production_Order__c" sidebar="false" showheader="true" recordSetVar="SCMC__Production_Order__c" extensions="TestExtension,TestExtension2">
<apex:form >
<apex:pageBlock rendered="True" title="Production Orders">
<apex:pageBlockSection title="Production Orders to Fill">
<apex:pageBlockTable value="{!objlist}" style="width:1220px" var="item">
<apex:column style="width:100px" headerValue="Production Order No." value="{!item.name}" />
<apex:column style="width:100px" value="{!item.Sales_Order_No__c}"/>
<apex:column style="width:100px" value="{!item.Customer__c}" headerValue="Customer Name"/>
<apex:column style="width:200px" value="{!item.Assembly_Name__c}" headerValue="Hose Description"/>
<apex:column style="width:150px" value="{!item.SCMC__Start_Date__c}" headerValue="Production Start Date"/>
<apex:column style="width:150px" value="{!item.SCMC__Planned_Completion_Date__c}" headerValue="Planned Completion Date"/>
<apex:column style="width:150px" value="{!item.SCMC__Production_Status__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection title="Production Order in Progress">
<apex:pageBlockTable value="{!objlist2}" style="width:1220px" var="item">
<apex:column style="width:100px" value="{!item.name}" headerValue="Production Order No."/>
<apex:column style="width:100px" value="{!item.Sales_Order_No__c}"/>
<apex:column style="width:100px" value="{!item.Customer__c}" headerValue="Customer Name"/>
<apex:column style="width:200px" value="{!item.Assembly_Name__c}" headerValue="Hose Description"/>
<apex:column style="width:150px" value="{!item.Hose_Assembly_By__c}" headerValue="Technician"/>
<apex:column style="width:150px" value="{!item.SCMC__Planned_Completion_Date__c}" headerValue="Planned Completion Date"/>
<apex:column style="width:150px" value="{!item.SCMC__Production_Status__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
TestExtension Class:
public class TestExtension {
public List<SCMC__Production_Order__c> objlist{get;set;}
public TestExtension(ApexPages.StandardSetController controller) {
objlist = [SELECT Name, Sales_Order_No__c, Customer__c, Assembly_Name__c, SCMC__Start_Date__c, SCMC__Planned_Completion_Date__c, SCMC__Production_Status__c
FROM SCMC__Production_Order__c Where SCMC__Production_Status__c = 'Pending Pulling All Items'];
}
}
TestExtension2 Class:
public class TestExtension2 {
public List<SCMC__Production_Order__c> objlist2{get;set;}
public TestExtension2(ApexPages.StandardSetController controller) {
objlist2 = [SELECT Name, Sales_Order_No__c, Customer__c, Assembly_Name__c,Hose_Assembly_By__c, SCMC__Planned_Completion_Date__c, SCMC__Production_Status__c
FROM SCMC__Production_Order__c Where SCMC__Production_Status__c = 'Pulled All Items'];
}
}