我有以下 visualforce 页面,需要通过 case.recortype 或 case.recordtype.id 字段过滤相关列表或 pageblocktables。谁能指导我找出如何做到这一点?谢谢
<apex:page standardController="Account" >
<apex:pageblock title="Cases" >
<apex:pageblockSection >
<apex:relatedList title="Support Cases" list="Cases"/>
</apex:pageblockSection>
<apex:pageblockSection >
<apex:relatedList title="Training Cases" list="Cases"/>
</apex:pageblockSection>
</apex:pageblock>
<apex:pageBlock title="Support Cases" >
<apex:pageBlockTable value="{!Account.Cases}" var="c">
<apex:column headervalue="Case"><apex:outputLink value="/{!c.id}">{!c.CaseNumber}</apex:outputLink></apex:column>
<apex:column value="{!c.Contact.Name}"/>
<apex:column value="{!c.Subject}"/>
<apex:column value="{!c.Priority}"/>
<apex:column value="{!c.CreatedDate}"/>
<apex:column value="{!c.status}"/>
<apex:column value="{!c.createdbyId}"/>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock title="Training Cases" >
<apex:pageBlockTable value="{!Account.Cases}" var="c">
<apex:column headervalue="Case"><apex:outputLink value="/{!c.id}">{!c.CaseNumber}</apex:outputLink></apex:column>
<apex:column value="{!c.Contact.Name}"/>
<apex:column value="{!c.Subject}"/>
<apex:column value="{!c.Priority}"/>
<apex:column value="{!c.CreatedDate}"/>
<apex:column value="{!c.status}"/>
<apex:column value="{!c.createdbyId}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
更新:这就是我最终做的事情:
页:
<apex:page standardController="account" extensions="SupportCasefilter,TrainingCasefilter">
<apex:form >
<apex:pageBlock title="Support Cases">
<apex:pageBlockTable value="{!SupportCases}" var="s">
<apex:column headervalue="Case"><apex:outputLink value="/{!s.id}">{!s.CaseNumber}</apex:outputLink></apex:column>
<apex:column value="{!s.Contact.Name}"/>
<apex:column value="{!s.Subject}"/>
<apex:column value="{!s.Priority}"/>
<apex:column value="{!s.CreatedDate}"/>
<apex:column value="{!s.status}"/>
<apex:column value="{!s.createdbyId}"/>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock title="Training Cases">
<apex:pageBlockTable value="{!TrainingCases}" var="t">
<apex:column headervalue="Case"><apex:outputLink value="/{!t.id}">{!t.CaseNumber}</apex:outputLink></apex:column>
<apex:column value="{!t.Contact.Name}"/>
<apex:column value="{!t.Subject}"/>
<apex:column value="{!t.Priority}"/>
<apex:column value="{!t.CreatedDate}"/>
<apex:column value="{!t.status}"/>
<apex:column value="{!t.createdbyId}"/>
<apex:column value="{!t.recordtype.id}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
控制器1:
public with sharing class SupportCasefilter {
public id accRecId;
public SupportCasefilter(ApexPages.StandardController controller) {
accRecId = [select id from account where id = :ApexPages.currentPage().getParameters().get('id')].id;
}
List<case> supportCases;
public List<case> getSupportCases() {
if(accRecId != null) {
supportCases= [SELECT Id, Contact.name, recordtype.id, casenumber, subject, priority, createddate, status, createdbyid
FROM Case
WHERE Record_Type__c='Support' AND account.id=:accRecId];
}
return supportCases;
}
}
控制器2:
public with sharing class TrainingCasefilter {
public id accRecId;
public TrainingCasefilter(ApexPages.StandardController controller) {
accRecId = [select id from account where id = :ApexPages.currentPage().getParameters().get('id')].id;
}
List<case> trainingCases;
public List<case> getTrainingCases() {
if(accRecId != null) {
trainingCases= [SELECT Id, Contact.name, recordtype.id, casenumber, subject, priority, createddate, status, createdbyid
FROM Case
WHERE Record_Type__c='Training' AND account.id=:accRecId];
}
return trainingCases;
}
}