You need to sign in to do that
Don't have an account?

Dividing page into sections
I have a visualforce page that lists data sorted be status and case number
Is it possible to divide the page into sections by status with a heading displaying the status?
Open Cases
1234
1235
1236
……..
Closed Cases
1237
1238
1238
……..
Thanks,
Haya
My page:
<apex:page standardController="Case" extensions="CaseExtension" tabStyle="My_Requests__tab">
<apex:stylesheet value="{/Resources.ForteStyles.css}" />
<style>
.hv{text-align:left;font-size:1.2em; color: #1fbdf2;font-weight:bold;}
</style>
<apex:pageBlock title="{!$User.FirstName} Requests" >
<apex:form >
<apex:dataTable value="{!cases}" var="s" columns="5" cellspacing="15" >
apex:commandButton value="Rerender" reRender="mid" oncomplete="initPageBlockTableEnhancer()"/>
<c:pageblocktableenhancer targetPbTableIds="mid,mid2" paginate="true" defaultPageSize="5" pageSizeOptions="5,10,20,30,40,50,100"/>
apex:pageBlockTable value="{! s.CaseNumber}" id="mid">
<apex:column headerValue="Request Number" headerClass="hv">
<apex:outputLink value="/apex/Viewed_Request_attachment?CaseNumber={!s.CaseNumber}">{! s.CaseNumber}</apex:outputLink>
</apex:column>
<apex:column value="{! s.Subject}" headerValue="Subject" headerClass="hv" />
<apex:column value="{! s.CreatedDate}" headerValue="Date/Time Opened" headerClass="hv" />
<apex:column value="{! s.Ownerid}" headerValue="Request Owner" headerClass="hv" />
<apex:column value="{! s.Status}" headerValue="Request Status" headerClass="hv" />
</apex:dataTable>
</apex:form>
</apex:pageBlock>
</apex:page>
My extension:
public class CaseExtension {
public list<Case> case1{get;set;}
public CaseExtension(ApexPages.StandardController controller) {
}
public list<Case> getcases()
{
case1=[Select Priority,CaseNumber,Accountid,Subject,Contactid,CreatedDate,Ownerid,Status from case where Ownerid=:UserInfo.getUserId() or Contactid=:UserInfo.getUserId() ORDER BY Status, CaseNumber ];
return case1;
}
}
This worked:
public class CaseExtension
{
public list<Case> caseOpen{get;set;}
public list<Case> caseClosed{get;set;}
public list<Case> case1{get;set;}
public CaseExtension(ApexPages.StandardController controller)
{
caseOpen = [Select Priority,CaseNumber,Accountid,Subject,Contactid,CreatedDate,Ownerid,Status,SuppliedName
from case
where ((Ownerid=:UserInfo.getUserId() or Contactid=:UserInfo.getUserId()) and (Status = 'New'))
ORDER BY Status, CaseNumber ];
caseClosed = [Select Priority,CaseNumber,Accountid,Subject,Contactid,CreatedDate,Ownerid,Status,SuppliedName
from case
where ((Ownerid=:UserInfo.getUserId() or Contactid=:UserInfo.getUserId()) and (Status <> 'New'))
ORDER BY Status, CaseNumber ];
}
public list<Case> getcases()
{
case1=[Select Priority,CaseNumber,Accountid,Subject,Contactid,CreatedDate,Ownerid,Status from case where Ownerid=:UserInfo.getUserId() or Contactid=:UserInfo.getUserId() ORDER BY Status, CaseNumber ];
return case1;
}
}
VF Page:
<apex:page standardController="Case" extensions="CaseExtension" tabStyle="My_Requests__tab">
<apex:stylesheet value="{/Resources.ForteStyles.css}" />
<style>
.hv{text-align:left;font-size:1.2em; color: #1fbdf2;font-weight:bold;}
</style>
<apex:pageBlock title="{!$User.FirstName} Requests" >
<apex:form >
<apex:PageBlockSection title="Current Requests" columns="1">
<apex:dataTable value="{!caseOpen}" var="s" cellspacing="15" >
apex:commandButton value="Rerender" reRender="mid" oncomplete="initPageBlockTableEnhancer()"/>
<c:pageblocktableenhancer targetPbTableIds="mid,mid2" paginate="true" defaultPageSize="5" pageSizeOptions="5,10,20,30,40,50,100"/>
apex:pageBlockTable value="{!s.CaseNumber}" id="mid">
<apex:column headerValue="Request Number" headerClass="hv">
<apex:outputLink value="/apex/Viewed_Request_attachment?CaseNumber={!s.CaseNumber}">{!s.CaseNumber}</apex:outputLink>
</apex:column>
<apex:column value="{!s.Subject}" headerValue="Subject" headerClass="hv" width="35%" />
<apex:column value="{!s.CreatedDate}" headerValue="Date/Time Opened" headerClass="hv"/>
<apex:column value="{!s.Ownerid}" headerValue="Request Owner" headerClass="hv"/>
<apex:column value="{!s.Status}" headerValue="Request Status" headerClass="hv"/>
<apex:column value="{!s.SuppliedName}" headerValue="Supplied Name" headerClass="hv"/>
</apex:dataTable>
</apex:PageBlockSection>
<apex:PageBlockSection title="Closed Requests" columns="1">
<apex:dataTable value="{!caseClosed}" var="c" cellspacing="15" >
apex:commandButton value="Rerender" reRender="mid" oncomplete="initPageBlockTableEnhancer()"/>
<c:pageblocktableenhancer targetPbTableIds="mid,mid2" paginate="true" defaultPageSize="5" pageSizeOptions="5,10,20,30,40,50,100"/>
apex:pageBlockTable value="{!c.CaseNumber}" id="mid">
<apex:column headerValue="Request Number" headerClass="hv">
<apex:outputLink value="/apex/Viewed_Request_attachment?CaseNumber={!c.CaseNumber}">{!c.CaseNumber}</apex:outputLink>
</apex:column>
<apex:column value="{!c.Subject}" headerValue="Subject" headerClass="hv" width="35%" />
<apex:column value="{!c.CreatedDate}" headerValue="Date/Time Opened" headerClass="hv" />
<apex:column value="{!c.Ownerid}" headerValue="Request Owner" headerClass="hv" />
<apex:column value="{!c.Status}" headerValue="Request Status" headerClass="hv" />
<apex:column value="{!c.SuppliedName}" headerValue="Supplied Name" headerClass="hv" />
</apex:dataTable>
</apex:PageBlockSection>
</apex:form>
</apex:pageBlock>
</apex:page>
All Answers
Hi
try this i hope this will help you.
public class CaseExtension1 {
public list<Case> case1{get;set;}
public list<Case> case2{get;set;}
public CaseExtension1(ApexPages.StandardController controller) {
}
public list<Case> getcases()
{
case1=[Select Priority,CaseNumber,Accountid,Subject,Contactid,CreatedDate,Ownerid,Status from case where (Ownerid=:UserInfo.getUserId() or Contactid=:UserInfo.getUserId()) and IsClosed=false];
return case1;
}
public list<Case> getcases1()
{
case2=[Select Priority,CaseNumber,Accountid,Subject,Contactid,CreatedDate,Ownerid,Status from case where (Ownerid=:UserInfo.getUserId() or Contactid=:UserInfo.getUserId()) and IsClosed=true];
return case2;
}
}
------------- vf page----------
<apex:page standardController="Case" extensions="CaseExtension" tabStyle="My_Requests__tab">
<apex:stylesheet value="{/Resources.ForteStyles.css}" />
<style>
.hv{text-align:left;font-size:1.2em; color: #1fbdf2;font-weight:bold;}
</style>
<apex:pageBlock title="{!$User.FirstName} closed Requests" >
<apex:form >
<apex:dataTable value="{!cases}" var="s" columns="5" cellspacing="15" >
apex:commandButton value="Rerender" reRender="mid" oncomplete="initPageBlockTableEnhancer()"/>
<c:pageblocktableenhancer targetPbTableIds="mid,mid2" paginate="true" defaultPageSize="5" pageSizeOptions="5,10,20,30,40,50,100"/>
apex:pageBlockTable value="{! s.CaseNumber}" id="mid">
<apex:column headerValue="Request Number" headerClass="hv">
<apex:outputLink value="/apex/Viewed_Request_attachment?CaseNumber={!s.CaseNumber}">{! s.CaseNumber}</apex:outputLink>
</apex:column>
<apex:column value="{! s.Subject}" headerValue="Subject" headerClass="hv" />
<apex:column value="{! s.CreatedDate}" headerValue="Date/Time Opened" headerClass="hv" />
<apex:column value="{! s.Ownerid}" headerValue="Request Owner" headerClass="hv" />
<apex:column value="{! s.Status}" headerValue="Request Status" headerClass="hv" />
</apex:dataTable>
</apex:form>
</apex:pageBlock>
<apex:pageBlock title="{!$User.FirstName} Openedd Requests" >
<apex:form >
<apex:dataTable value="{!cases1}" var="s" columns="5" cellspacing="15" >
apex:commandButton value="Rerender" reRender="mid" oncomplete="initPageBlockTableEnhancer()"/>
<c:pageblocktableenhancer targetPbTableIds="mid,mid2" paginate="true" defaultPageSize="5" pageSizeOptions="5,10,20,30,40,50,100"/>
apex:pageBlockTable value="{! s.CaseNumber}" id="mid">
<apex:column headerValue="Request Number" headerClass="hv">
<apex:outputLink value="/apex/Viewed_Request_attachment?CaseNumber={!s.CaseNumber}">{! s.CaseNumber}</apex:outputLink>
</apex:column>
<apex:column value="{! s.Subject}" headerValue="Subject" headerClass="hv" />
<apex:column value="{! s.CreatedDate}" headerValue="Date/Time Opened" headerClass="hv" />
<apex:column value="{! s.Ownerid}" headerValue="Request Owner" headerClass="hv" />
<apex:column value="{! s.Status}" headerValue="Request Status" headerClass="hv" />
</apex:dataTable>
</apex:form>
</apex:pageBlock>
</apex:page>
regards
venkatesh.
Hi,
Use map to display data as per your requirement:
------------------------- VF Code --------------------------
<apex:page standardController="Case" extensions="CaseExtension">
<apex:form>
<apex:pageBlock>
<apex:repeat value="{!cases}" var="caselist">
<b>{!caseList}</b> <!--- this show the case Status ----->
<table border="1px" cellspacing="0" cellpadding="0">
<tr>
<th> Case Number </th>
<th>Priority </th>
</tr>
<apex:repeat value="{!cases[caseList]}" var="case">
<tr>
<td width="20px;">
<apex:outputText value="{!case.CaseNumber}"></apex:outputText>
</td>
<td>
<apex:outputText value="{!case.Priority}"></apex:outputText>
</td>
</tr>
</apex:repeat>
</table>
</apex:repeat>
</apex:pageBlock>
</apex:form>
</apex:page>
-----------------------------------Apex-------------------------------
Public Class CaseExtension {
public CaseExtension(ApexPages.StandardController controller) {}
public Map<String,List<Case>> getcases(){
Map<String,List<Case>> caseMap = new Map<String,List<Case>>();
List<case> csList;
for( Case cs : [Select Priority,CaseNumber,Accountid,Subject,Contactid,CreatedDate,Ownerid,Status from
case where Ownerid=:UserInfo.getUserId() or Contactid=:UserInfo.getUserId()
ORDER BY Status, CaseNumber ] )
{
csList = new List<case>();
if( caseMap != null && caseMap.containsKey(cs.Status)) {
csList = caseMap.get(cs.Status);
}
csList.add( cs);
caseMap.put(cs.Status,csList);
}
return caseMap;
}
}
Please let me know if u have any problem on same and if this post helps you please give KUDOS by click on star at left.
Hi Puja,
I am not able to understand this line. We have not written any getter-setter for {!caseList}?
<b>{!caseList}</b> <!--- this show the case Status ----->
This worked:
public class CaseExtension
{
public list<Case> caseOpen{get;set;}
public list<Case> caseClosed{get;set;}
public list<Case> case1{get;set;}
public CaseExtension(ApexPages.StandardController controller)
{
caseOpen = [Select Priority,CaseNumber,Accountid,Subject,Contactid,CreatedDate,Ownerid,Status,SuppliedName
from case
where ((Ownerid=:UserInfo.getUserId() or Contactid=:UserInfo.getUserId()) and (Status = 'New'))
ORDER BY Status, CaseNumber ];
caseClosed = [Select Priority,CaseNumber,Accountid,Subject,Contactid,CreatedDate,Ownerid,Status,SuppliedName
from case
where ((Ownerid=:UserInfo.getUserId() or Contactid=:UserInfo.getUserId()) and (Status <> 'New'))
ORDER BY Status, CaseNumber ];
}
public list<Case> getcases()
{
case1=[Select Priority,CaseNumber,Accountid,Subject,Contactid,CreatedDate,Ownerid,Status from case where Ownerid=:UserInfo.getUserId() or Contactid=:UserInfo.getUserId() ORDER BY Status, CaseNumber ];
return case1;
}
}
VF Page:
<apex:page standardController="Case" extensions="CaseExtension" tabStyle="My_Requests__tab">
<apex:stylesheet value="{/Resources.ForteStyles.css}" />
<style>
.hv{text-align:left;font-size:1.2em; color: #1fbdf2;font-weight:bold;}
</style>
<apex:pageBlock title="{!$User.FirstName} Requests" >
<apex:form >
<apex:PageBlockSection title="Current Requests" columns="1">
<apex:dataTable value="{!caseOpen}" var="s" cellspacing="15" >
apex:commandButton value="Rerender" reRender="mid" oncomplete="initPageBlockTableEnhancer()"/>
<c:pageblocktableenhancer targetPbTableIds="mid,mid2" paginate="true" defaultPageSize="5" pageSizeOptions="5,10,20,30,40,50,100"/>
apex:pageBlockTable value="{!s.CaseNumber}" id="mid">
<apex:column headerValue="Request Number" headerClass="hv">
<apex:outputLink value="/apex/Viewed_Request_attachment?CaseNumber={!s.CaseNumber}">{!s.CaseNumber}</apex:outputLink>
</apex:column>
<apex:column value="{!s.Subject}" headerValue="Subject" headerClass="hv" width="35%" />
<apex:column value="{!s.CreatedDate}" headerValue="Date/Time Opened" headerClass="hv"/>
<apex:column value="{!s.Ownerid}" headerValue="Request Owner" headerClass="hv"/>
<apex:column value="{!s.Status}" headerValue="Request Status" headerClass="hv"/>
<apex:column value="{!s.SuppliedName}" headerValue="Supplied Name" headerClass="hv"/>
</apex:dataTable>
</apex:PageBlockSection>
<apex:PageBlockSection title="Closed Requests" columns="1">
<apex:dataTable value="{!caseClosed}" var="c" cellspacing="15" >
apex:commandButton value="Rerender" reRender="mid" oncomplete="initPageBlockTableEnhancer()"/>
<c:pageblocktableenhancer targetPbTableIds="mid,mid2" paginate="true" defaultPageSize="5" pageSizeOptions="5,10,20,30,40,50,100"/>
apex:pageBlockTable value="{!c.CaseNumber}" id="mid">
<apex:column headerValue="Request Number" headerClass="hv">
<apex:outputLink value="/apex/Viewed_Request_attachment?CaseNumber={!c.CaseNumber}">{!c.CaseNumber}</apex:outputLink>
</apex:column>
<apex:column value="{!c.Subject}" headerValue="Subject" headerClass="hv" width="35%" />
<apex:column value="{!c.CreatedDate}" headerValue="Date/Time Opened" headerClass="hv" />
<apex:column value="{!c.Ownerid}" headerValue="Request Owner" headerClass="hv" />
<apex:column value="{!c.Status}" headerValue="Request Status" headerClass="hv" />
<apex:column value="{!c.SuppliedName}" headerValue="Supplied Name" headerClass="hv" />
</apex:dataTable>
</apex:PageBlockSection>
</apex:form>
</apex:pageBlock>
</apex:page>