• Pooja Chawla 3
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hi,

 

I am trying to display the cases based on option selected by the user. I have two options open incidents and closed incidents. By default it will display open incidents. when user selects closed incidents it should display all the closed incidents. I somehow managed to build this. But the pagination is not working properly. For the datatable to refresh I have seen in other posts, that we should not use if(con==null) --  this will not refresh the table. I have commented that part. The moment I have commented that line in my controller, pagination is not working. Could anyhelp me with this issue. Below is my visaluforce page and the controller :

 

 

<apex:page sidebar="false" controller="MyIncidentsPageController">

<script>
var val;
function changeCaseType(changedvalue){
val = changedvalue.value;
setCaseStatusMethod(val);
}
</script>
<apex:form >
<apex:outputPanel >
<apex:selectRadio value="{!caseType}" onchange="changeCaseType(this)">
<apex:selectOptions value="{!items}">
</apex:selectOptions>
</apex:selectRadio>
</apex:outputPanel>
<apex:actionFunction action="{!setCaseStatusMethod}" name="setCaseStatusMethod">
</apex:actionFunction>
<apex:outputPanel style="padding:10px;display:block;" id="caseList">
<apex:dataTable value="{!Cases}" var="OI" headerClass="header" style="border-style:solid;border-width:2px;border-color:#c8c8c8;" rowClasses="odd,even" width="100%">
<apex:column headerValue="Incident" style="padding:10px;">
<apex:outputText >{!OI.CaseNumber}</apex:outputText>
</apex:column>
<apex:column value="{!OI.Created__c}" headerValue="Created" style="padding:10px;color:#2f627f;"/>
<apex:column value="{!OI.Modified__c}" headerValue="Modified" style="padding:10px;color:#2f627f;"/>
<apex:column value="{!OI.Priority}" headerValue="Priority" style="padding:10px;color:#2f627f;"/>
<apex:column value="{!OI.Productweb__c}" headerValue="Product" style="padding:10px;color:#2f627f;"/>
<apex:column value="{!OI.Submitted_By__c}" headerValue="Submitted By" style="padding:10px;color:#2f627f;"/>
<apex:column value="{!OI.Subject}" headerValue="Subject" style="padding:10px;color:#2f627f;"/>
<apex:column value="{!OI.Status}" headerValue="Status" style="padding:10px;color:#2f627f;"/>
</apex:dataTable>
<apex:panelGrid columns="3" style="float:right;" id="links">
<apex:commandLink action="{!previous}" rendered="{!hasPrevious}" style="padding:12px;">Previous</apex:commandlink>
<apex:outputLabel rendered="{!(hasPrevious && hasNext)}" >|</apex:outputLabel>
<apex:commandLink action="{!next}" rendered="{!hasNext}" style="padding:12px;">Next</apex:commandlink>
</apex:panelGrid><br/>
</apex:outputPanel>
<apex:outputpanel style="float:right;display:block;margin-right:7px;padding-top:2px;">

</apex:outputPanel>
</apex:form>
</apex:page>

 

 

Here is my controller

 

 

public with sharing class MyIncidentsPageController {

public List<Case> caseList {get;set;}
String caseType;
public String caseStatus {get;set;}

public String getcaseType(){
return caseType;
}

public void setcaseType(String caseType){
this.caseType = caseType;
}

public PageReference setCaseStatusMethod(){
caseStatus = caseType;
return null;
}

public MyIncidentsPageController(){
caseType='Open';
caseStatus='Open';
}

public List<SelectOption> getItems(){
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('Open','Open Incidents'));
options.add(new SelectOption('Closed','Closed Incidents'));
return options;
}

public ApexPages.StandardSetController con{
get{
// if(con==null){
con = new ApexPages.StandardSetController(Database.getQueryLocator([select Id,Subject,CaseNumber, Resolution__c,AccountId, Status, Priority,Productweb__c, Created__c,Modified__c,Submitted_By__c,CreatedDate from Case where status=:caseStatus order by CreatedDate desc]));
con.setPageSize(10);
// }
return con;
}
set;
}

public Boolean hasNext{
get{
return con.getHasNext();
}
set;
}

public Boolean hasPrevious {
get{
return con.getHasPrevious();
}
set;
}

public void next(){
con.next();
}

public void previous(){
con.previous();
}

public List<Case> getCases(){
caseList = con.getRecords();
return caseList;
}

}

 

 

 

Thanks in advance.

  • April 13, 2011
  • Like
  • 0