Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
372 views
in Technique[技术] by (71.8m points)

salesforce - Visualforce Custom Controller List

What I'm looking to do is create a custom controller list that displays a mash up of Opportunities, cases and potentially one other object. I started using the class from the visualforce guide to get me going:

public with sharing class CasePagination {
private final Case c;

public CasePagination(ApexPages.StandardSetController controller) {
this.c = (Case)controller.getRecord();
}
public ApexPages.StandardSetController CaseRecords{
get {
if(CaseRecords == null) {
return new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT c.CaseNumber, c.AccountId, c.Subject, c.Status FROM Case c]));
}
return CaseRecords;
}
private set;
}
public List<Case> getCasePagination() {
return (List<Case>) CaseRecords.getRecords();
}
}

I adapted some visualforce code to display a list of cases for now:

<apex:page standardController="Case" recordSetvar="cases" extensions="CasePagination">

<apex:pageBlock title="Viewing Cases">
<apex:form id="theForm">

<apex:pageBlockTable value="{!CasePagination}" var="c">
<apex:outputLink value="{!c.Id}">{!c.CaseNumber}</apex:outputLink>
<apex:column value="{!c.Id}"/>
<apex:column value="{!c.CaseNumber}" />
<apex:column value="{!c.Subject}" onclick="openCase"/>
<apex:column value="{!c.Status}" onclick="openCase"/>
</apex:pageBlockTable>

<apex:panelGrid columns="2">
</apex:panelGrid>
</apex:form>
</apex:pageBlock>
</apex:page>

What I'm trying to do now is make the items in the table clickable. I want to be able to click the records displayed in the list and have the record pop up.

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could use an outputLink:

<apex:pageBlockTable value="{!CasePagination}" var="c">
    <apex:column value="{!c.Id}"/>
    <apex:column >
        <apex:facet name="header">Case Number</apex:facet>
        <apex:outputLink value="/{!c.Id}">{!c.CaseNumber}</apex:outputLink>
    </apex:column>
    <apex:column value="{!c.Subject}" onclick="openCase"/>
    <apex:column value="{!c.Status}" onclick="openCase"/>
</apex:pageBlockTable>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...