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

Pagination Class for Tasks
I have the following pagination code/vf page. I am getting an error that says 'List controllers are not supported for Task '. How can I update the code to make the visualforce page work?
Apex:
VisualForce:
Apex:
public class PaginationTaskHomePage1{ public String soql {get;set;} public List <Task> TaskList1 = New List <Task>(); public String soqlsort {get;set;} public List <Task> TaskList2= New List <Task>(); Public Integer noOfRecords{get; set;} Public Integer size{get;set;} public List <Task> getTaskList() { return con.getRecords(); } public Apexpages.StandardSetController con{ get{ if(con==null){ size=500; string OwnersId = userinfo.getUserId() ; string type1 = 'Lost NB Round 1'; string type2 = 'Lost Renewals'; soqlsort='Select Subject,WhoID,WhatId,OwnerId,Opportunity_Effective_Date__c,Primary_Medical_Effective_Date__c,Type,CreatedDate From Task Where OwnerId = :OwnersId AND (Type = :type1 OR Type= :type2)'; TaskList1 = Database.query(soqlsort + ' Order by ' + sortField +' ' + sortDir); con= new ApexPages.StandardSetController(TaskList1); con.setPageSize(size); noOfRecords=Con.getResultSize(); } return con; } set; } public Boolean hasNext { get { return con.getHasNext(); } set; } //indicates whether therre are more records before the current page set. public Boolean hasPrevious{ get{ return con.getHasPrevious(); } set; } public Integer pageNumber { get{ return con.getPageNumber(); } set; } public void next(){ con.next(); } //returns the PageRerfernce of the original page, if known, or home page. public void cancel() { con.cancel(); } // Method for Constructor is used for Test Class public PaginationTaskHomePage1() { } //Toggles the sorting of query from asc to desc public void toggleSort() { //simply toggle the direction sortDir= sortDir.equals('asc') ? 'desc' : 'asc'; //run the query again for sorting other columns string OwnersId = userinfo.getUserId() ; string type1 = 'Lost NB Round 1'; string type2 = 'Lost Renewals'; soqlsort = 'Select Subject,WhoID,WhatId,OwnerId,Opportunity_Effective_Date__c,Primary_Medical_Effective_Date__c,Type,CreatedDate From Task Where OwnerId = :OwnersId AND (Type = :type1 OR Type= :type2)'; //adding string array to a List array TaskList2 = Database.query(soqlsort + ' Order by ' + sortField + ' ' + sortDir); // Adding Caselist to standard Pagination controller variable con= new ApexPages.StandardSetController(TaskList2); //Set Page Size to 500 con.setPageSize(500); } //the current sort direction defaults to asc public String sortDir{ //To set a direction either in ascending order or descending order. get{if(sortDir==null){sortDir = 'asc';} return sortDir;} set; } //the current field to sort by. defaults to probability public String sortField{ //to set a field sorting. get{if (sortField==null){sortField='Opportunity_Effective_Date__c';} return sortField;} set; } public pageReference refresh() { Con = null; getTaskList(); Con.setPageNumber(1); return null; } }
VisualForce:
<apex:page controller="PaginationTaskHomePage1" tabstyle="Task"> <apex:form > <apex:pageBlock id="pb"> <apex:sectionHeader title="{!$User.FirstName}'s Lost Renewal & New Business List"/> <apex:commandButton value="New Opportunity" onClick="window.open('https://cs15.salesforce.com/006/e?retURL=%2F006%2Fo&RecordType=01240000000Uexl&ent=Opportunity');"/> <apex:commandButton value="Detailed Report" onClick="window.open('https://cs15.salesforce.com/00Oe0000000fRSG');"/> <apex:pageBlockTable value="{!TaskList}" var="o" id="myTable"> <apex:column > <apex:facet name="header"> <apex:commandLink value="Subject" action="{!toggleSort}" reRender="pb"> <apex:param name="sortField" value="Subject" assignTo="{!sortField}" /> </apex:commandLink> </apex:facet> <apex:outputlink value="/{!o.subject}" target="__blank">{!o.subject}</apex:outputlink> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="WhoID" action="{!toggleSort}" reRender="pb"> <apex:param name="sortField" value="WhoId" assignTo="{!sortField}" /> </apex:commandLink> </apex:facet> <apex:outputField value="{!o.WhoId}" /> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="WhatId" action="{!toggleSort}" reRender="pb"> <apex:param name="sortField" value="WhatId" assignTo="{!sortField}" /> </apex:commandLink> </apex:facet> <apex:outputField value="{!o.WhatId}" /> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="OwnerId" action="{!toggleSort}" reRender="pb"> <apex:param name="sortField" value="OwnerId" assignTo="{!sortField}" /> </apex:commandLink> </apex:facet> <apex:outputlink value="/{!o.OwnerId}" target="__blank">{!o.OwnerId}</apex:outputlink> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="Opportunity_Effective_Date__c" action="{!toggleSort}" reRender="pb"> <apex:param name="sortField" value="Opportunity_Effective_Date__c" assignTo="{!sortField}" /> </apex:commandLink> </apex:facet> <apex:outputField value="{!o.Opportunity_Effective_Date__c}" /> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="Primary_Medical_Effective_Date__c" action="{!toggleSort}" reRender="pb"> <apex:param name="sortField" value="Primary_Medical_Effective_Date__c" assignTo="{!sortField}" /> </apex:commandLink> </apex:facet> <apex:outputField value="{!o.Primary_Medical_Effective_Date__c}" /> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="Type" action="{!toggleSort}" reRender="pb"> <apex:param name="sortField" value="Type" assignTo="{!sortField}" /> </apex:commandLink> </apex:facet> <apex:outputField value="{!o.Type}" /> </apex:column> <apex:column > <apex:facet name="header"> <apex:commandLink value="Create Date" action="{!toggleSort}" reRender="pb"> <apex:param name="sortField" value="CreatedDate" assignTo="{!sortField}" /> </apex:commandLink> </apex:facet> <apex:outputField value="{!o.CreatedDate}" /> </apex:column> </apex:pageBlockTable> <apex:panelGrid columns="7"> <apex:commandButton status="fetchStatus" reRender="pb" value="|<" action="{!Con.first}" disabled="{!!Con.hasPrevious}" title="First Page"/> <apex:commandButton status="fetchStatus" reRender="pb" value="<" action="{!Con.previous}" disabled="{!!Con.hasPrevious}" title="Previous Page"/> <apex:commandButton status="fetchStatus" reRender="pb" value=">" action="{!Con.next}" disabled="{!!Con.hasNext}" title="Next Page"/> <apex:commandButton status="fetchStatus" reRender="pb" value=">|" action="{!Con.last}" disabled="{!!Con.hasNext}" title="Last Page"/> <apex:outputText >{!(Con.pageNumber * size)+1-size}-{!IF((Con.pageNumber * size)>noOfRecords, noOfRecords,(Con.pageNumber * size))} of {!noOfRecords}</apex:outputText> <apex:commandButton status="fetchStatus" reRender="pb" value="Refresh" action="{!refresh}" title="Refresh Page"/> <apex:outputPanel style="color:#4AA02C;font-weight:bold"> <apex:actionStatus id="fetchStatus" startText="Fetching..." stopText=""/> </apex:outputPanel> </apex:panelGrid> </apex:pageBlock> </apex:form> </apex:page>
I'm guessing this is down to some of the bespoke funcitonality inculded in order items around saving and discount calculations etc..
I think you're going to have to implement pagination manually, you could either query everything and do paging, or use the SOQL OFFSET keyword to pull different pages of data from the DB.
One other alternative is to send all items through to the page and do it through a jQuery plugin or similar, though you'd want to be sure you're not sending hundreds of records back and forth for performance reasons (this does seem unlikely but it'll depend on the business).
plesae find the reference link for using offset in SOQL query
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_offset.htm
hope this will helps you.
Thanks
karthik
https://hisrinu.wordpress.com/2012/01/09/pagination-using-standardsetcontroller/
Check this Link for the pagination using the standard set controller.
Thanks
Vinuthh S
Check this link
apex
VF