Skip to main content
deleted 105 characters in body
Source Link
Rao
  • 16.8k
  • 13
  • 69
  • 108

Experts correct me if I am wrong and can someway use standardsetcontroller to do this more effective!!!

Experts correct me if I am wrong and can someway use standardsetcontroller to do this more effective!!!

Source Link
Rao
  • 16.8k
  • 13
  • 69
  • 108

First of I am not sure if you can get the Recently Viewed cases and all cases.

I managed to modify the code as below :

PAGE:

<apex:page controller="CompanyCasesQue" sidebar="true" showHeader="true">
    <apex:form >
        <apex:pageBlock title="My Cases">
              <apex:outputLabel value="View:"/>
              <apex:selectList value="{!filterId}" size="1">
                <apex:actionSupport event="onchange" action="{!renderdiffview}" rerender="cases_table"/>
                <apex:selectOptions value="{!items}"/>
              </apex:selectList>
            <apex:pageBlock >
                <apex:pageBlockTable value="{!results}" var="c" rows="50" id="cases_table">
                    <apex:column >
                        <a target="_parent" href="/{!c.id}">{!c.CaseNumber}</a>
                        <apex:facet name="header">Case Number</apex:facet>
                    </apex:column>
                </apex:pageBlockTable>
            </apex:pageBlock>
        </apex:pageBlock>
    </apex:form>
</apex:page>

controller :

global class CompanyCasesQue {
public string FilterId{get;set;}
public list<case> results;
    //constructors and variable declaration

    public PageReference renderdiffview() {
    Map<Id,string> Id_status_map = new map<Id,string>{'00BW0000000PeSVMA0' => 'New','00BW0000000PeSGMA0' => 'Closed'};
    results = [select id,casenumber from case where status =: Id_status_map.get(filterId)];
     return null;
    }
    
    public List<Case> getresults() {       
     return results;
    }
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('00BW0000000PeSVMA0','View All Open Cases'));
        options.add(new SelectOption('00BW0000000PbzWMAS','View All Cases'));
        options.add(new SelectOption('00BW0000000PeSGMA0','View All Closed Cases'));
        options.add(new SelectOption('00B300000005XQtEAM','Recently Viewed Cases'));
        return options;
    }
}

I have a map in the controller since the filter Id is the Id = '00BW0000000PeSVMA0' being sent from page. I mapped all open cases and closed cases to status = open and status = closed.

for all open Cases I would go a diff route and use pagination since there might be multiple cases.

Experts correct me if I am wrong and can someway use standardsetcontroller to do this more effective!!!