在Salesforce.com上,您可以按记录类型筛选apex:pageBlockTable吗?

在Salesforce.com上,您可以按记录类型筛选apex:pageBlockTable吗?,salesforce,visualforce,apex,Salesforce,Visualforce,Apex,我有下面的visualforce页面,需要按case.recortype或case.recordtype.id字段筛选相关列表或pageblocktables。有谁能指导我如何做到这一点吗?谢谢 <apex:page standardController="Account" > <apex:pageblock title="Cases" > <apex:pageblockSection > <apex:relatedList tit

我有下面的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>

{!c.案例编号}
{!c.案例编号}
更新:这就是我最终要做的:

第页:


{!s.CaseNumber}
{!t.CaseNumber}

控制员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;
    }    

}
public与共享类SupportCasefilter{
公共身份证;
公共支持案例过滤器(ApexPages.StandardController){
accRecId=[从id=:ApexPages.currentPage().getParameters().get('id')].id的帐户中选择id;
}
列出支持案例;
公共列表getSupportCases(){
if(accRecId!=null){
supportCases=[选择Id、Contact.name、recordtype.Id、casenumber、主题、优先级、createddate、状态、createdbyid
从案例
其中记录_Type_uc='Support'和account.id=:accRecId];
}
返回支持案例;
}    
}
控制员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;
    }    

}
public与共享类培训案例过滤器{
公共身份证;
公共培训案例过滤器(ApexPages.StandardController){
accRecId=[从id=:ApexPages.currentPage().getParameters().get('id')].id的帐户中选择id;
}
列出培训案例;
公共列表getTrainingCases(){
if(accRecId!=null){
trainingCases=[选择Id、Contact.name、recordtype.Id、案例编号、主题、优先级、createddate、状态、createdbyid
从案例
其中记录_Type_uc='Training'和account.id=:accRecId];
}
返回培训案例;
}    
}

我建议在将结果传递到pageBlockTable之前,使用SOQL查询在控制器内部应用记录类型筛选器。

以下是我过去所做的:

1-创建一个
列表validRecordTypes
,其中包含控制器中的有效记录类型ID

2-使用控制器中的列表
validRecordTypes
筛选对象
Account.Cases


3-当您尝试访问VisualForce页面中的
Account.Cases
时,对象应为后筛选对象

谢谢,我需要在自定义控件中执行此操作吗?我是Apex和Visualforce的新手。是的,但是如果你是Apex新手,你可以创建一个标准的控制器扩展,这可能会让你的生活更轻松。你能举个例子说明如何做到这一点吗?我仍在试图弄清楚如何使用apex中的控制器。
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;
    }    

}