Then your Controller will look something like this:
public class CaseList
{
private ApexPages.StandardSetController ssc;
public CaseList
{
List<Case> caseList = [SELECT Name FROM Case];
ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(caseList);
ssc.setFilterID(YourFilterId);
}
public List<Case> getCases()
{
return (List<Case>)ssc.getRecords();
}
}
Hope this helps.
Kindly mark this as solved if the information was helpful.
How can i get the data of case as per login user- sorting process not working
Apex page public class NewCaseList { List<Case> results = [Select CaseNumber, Subject, Priority, Origin FROM Case WHERE OwnerId= :UserInfo.getUserID()];
public List<Case> getresults() { return results; }
List<Case> results1 = [SELECT CaseNumber,Origin,Priority,Subject FROM Case WHERE Priority = 'High' ];
public List<Case> getresults1() { return results1; } public NewCaseList() { List<Case> caseList = [Select CaseNumber, Subject, Priority, Origin FROM Case WHERE OwnerId= :UserInfo.getUserID()]; ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(caseList); ssc.setFilterId(filterId); } public List<Case> getCases() { return (List<Case>)ssc.getRecords(); }
}
Visual force page <apex:page standardController="Case" recordSetvar="case">
Below is the visual force page which renders a list of cases.
You have a few options, you could use an apex:enhancedList on your Visualforce page, which is covered in the documentation here(https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_enhancedList.htm). Alternatively, you can use a Standard List Controller(https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_sosc_about.htm) (with an apex: repeat, apex:dataTable or apex:pageBlockTable and set the fcf parameter in your URL to the desired List View ID. Then navigate to the page using a URL similar to this:
Finally, you can use a StandardSetController within a Custom Controller and set the desired ListView in Apex using setFilterID, which is covered in the documentation here(https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_ApexPages_StandardSetController_setFilterID.htm). Then your Controller will look something like this: Hope this helps.
Kindly mark this as solved if the information was helpful.
Thanks,
Nagendra
Apex page
public class NewCaseList {
List<Case> results = [Select CaseNumber, Subject, Priority, Origin FROM Case WHERE OwnerId= :UserInfo.getUserID()];
public List<Case> getresults()
{
return results;
}
List<Case> results1 = [SELECT CaseNumber,Origin,Priority,Subject FROM Case WHERE Priority = 'High' ];
public List<Case> getresults1()
{
return results1;
}
public NewCaseList()
{
List<Case> caseList = [Select CaseNumber, Subject, Priority, Origin FROM Case WHERE OwnerId= :UserInfo.getUserID()];
ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(caseList);
ssc.setFilterId(filterId);
}
public List<Case> getCases()
{
return (List<Case>)ssc.getRecords();
}
}
Visual force page
<apex:page standardController="Case" recordSetvar="case">
<apex:pageBlock title="Viewing Cases">
<apex:form id="theForm">
<apex:panelGrid columns="2">
<apex:selectList value="{!filterId}" size="1">
<apex:actionSupport event="onchange" rerender="list"/>
<apex:selectOptions value="{!listviewoptions}"/>
</apex:selectList>
</apex:panelGrid>
<apex:pageBlock>
<apex:pageBlockTable var="a" value="{!Case}" id="list" >
<apex:column>
<apex:outputLink value="{! URLFOR($Action.Case.Edit, a.Id) }">
Edit
</apex:outputLink>
<apex:outputLink value="{! URLFOR($Action.Case.Delete, a.Id) }">
Del
</apex:outputLink>
</apex:column>
<apex:column value="{!a.CaseNumber}"/>
<apex:column value="{!a.Priority}"/>
<apex:column value="{!a.Subject}"/>
<apex:column value="{!a.Origin}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:pageBlock>
</apex:page>