You need to sign in to do that
Don't have an account?
Help With PageBlockTable Conditions
Hello:
I cannot figure out what to do here. Here is my situation:
I have a custom obeject Zip_Code__c that is in a Master-Detail with custom object Sites__c. The relationship name is References__r.
Sites__c has five different record types and what I want to do is create related lists for each RecordType individually. I am attempting to do this through Visualforce. Below is my VF page and extension.
<apex:page standardcontroller="Zip_Code__c" extensions="RFMDU"> <apex:pageBlock > <apex:pageBlockTable value="{!Zip_Code__c.Releases__r}" var="zip" width="100%" columns="5"> <apex:column id="c5" headerValue="MDU"> <apex:outputField value="{!zip.Name}"/> </apex:column> <apex:column id="c4" headerValue="Units"> <apex:outputField value="{!zip.Units__c}"/> </apex:column> <apex:column id="c3" headerValue="Account Manager"> <apex:outputField value="{!zip.Account_Manager__c}"/> </apex:column> <apex:column id="c2" headerValue="Release Date"> <apex:outputField value="{!zip.Released_To_Sales__c}"/> </apex:column> <apex:column id="c1" headerValue="Zip Code"> <apex:outputField value="{!zip.Zip_Code__c}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:page>
public class RFMDU { //private final Sites__c sites; private List<Sites__c> sites = new List<Sites__c>(); public RFMDU(Apexpages.StandardController controller) { String zipCodeId = controller.getId(); sites = [SELECT ID, RecordTypeID FROM Sites__c WHERE Zip_Code__c = :zipCodeId AND RecordTypeId='012C0000000GEJzIAO']; } public List<Sites__c> getsites() { return sites; } public PageReference save() { update sites; return null; } }
What I am trying to acomplish is for this pageblockTable to display only related objects with RecordTypeID=012C0000000GEJzIAO. I am at a loss. Can anyone help me out here? Is my Controller not written correctly? Am I missing something in my VF code?
Thanks in advance,
Matt
Hi
The page block table is shows only related objects with record type id ='012C0000000GEJzIAO' because you query in controller getting only this record types.
1. you need query all sites records in single query . i.e need to remove below condition
you can display all sites records where zip code equals to current zip code.
2. if you want different page block tables different record types
use "rerendered " tag in page block table.
try this,
Therefore, you should get records of a specific Record Type from your controller.
Maybe I mis-stated my original question. The goal was to ONLY get those records with the record type that is in the controller. I have made the changes suggested in the controller and it is still pulling all record back. I also attempted to use the "rerender" option but that does not appear to be valid in any place in my VF code.
I used render instead and it worked - except for it left blank rows where the condition was not met.
Any other suggestions?
Have you revised your VF page, like,
apex:pageBlockTable value="{!sites}",.....
You have to show what you queried in the Controller on your page.