You need to sign in to do that
Don't have an account?
Alex Kirby
Use variable in Apex for Dynamic list view
Hi All,
I would like to pass a variable to myu apex class to filter the list view returned:
I would like to add a field called category on to the visualforce page and have the SOQL where clause filter by the users selection i.e. if they select 'billing' I would want the query to be Select id, CaseNumber, ContactId, Subject, Status, Priority, CreatedDate from Case where category__c = billing'
Help is always appreciated, thanks
Class:
I would like to pass a variable to myu apex class to filter the list view returned:
I would like to add a field called category on to the visualforce page and have the SOQL where clause filter by the users selection i.e. if they select 'billing' I would want the query to be Select id, CaseNumber, ContactId, Subject, Status, Priority, CreatedDate from Case where category__c = billing'
Help is always appreciated, thanks
Class:
public with sharing class Pagination { Public Integer noOfRecords{get; set;} Public Integer size{get;set;} public ApexPages.StandardSetController setCon { get{ if(setCon == null){ size = 20; string queryString = 'Select id, CaseNumber, ContactId, Subject, Status, Priority, CreatedDate from Case'; setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString)); setCon.setPageSize(size); noOfRecords = setCon.getResultSize(); } return setCon; }set; } Public List<Case> getCases(){ List<Case> caseList = new List<Case>(); for(Case C : (List<Case>)setCon.getRecords()) caseList.add(C); return caseList; } public pageReference refresh() { setCon = null; getCases(); setCon.setPageNumber(1); return null; } public Boolean hasNext { get { return setCon.getHasNext(); } set; } public Boolean hasPrevious { get { return setCon.getHasPrevious(); } set; } public Integer pageNumber { get { return setCon.getPageNumber(); } set; } public void first() { setCon.first(); } public void last() { setCon.last(); } public void previous() { setCon.previous(); } public void next() { setCon.next(); } }VF:
<apex:page controller="Pagination" showHeader="false"> <apex:pageBlock id="pb" mode="maindetail"> <apex:pageBlockTable value="{!Cases}" var="a" > <apex:column headerValue="Case Number"> <apex:outputlink value="/qmt_CaseDetail?id={!a.id}">{!a.CaseNumber}</apex:outputlink> </apex:column> <apex:column value="{!a.ContactId}"/> <apex:column value="{!a.Subject}"/> <apex:column value="{!a.Status}"/> <apex:column value="{!a.Priority}"/> <apex:column value="{!a.CreatedDate}"/> </apex:pageBlockTable> <apex:panelGrid columns="7"> <apex:commandButton styleClass="metro" status="fetchStatus" reRender="pb" value="|<" action="{!first}" disabled="{!!hasPrevious}" title="First Page"/> <apex:commandButton styleClass="metro" status="fetchStatus" reRender="pb" value="<" action="{!previous}" disabled="{!!hasPrevious}" title="Previous Page"/> <apex:commandButton styleClass="metro" status="fetchStatus" reRender="pb" value=">" action="{!next}" disabled="{!!hasNext}" title="Next Page"/> <apex:commandButton styleClass="metro" status="fetchStatus" reRender="pb" value=">|" action="{!last}" disabled="{!!hasNext}" title="Last Page"/> <apex:outputText >{!(pageNumber * size)+1-size}-{!IF((pageNumber * size)>noOfRecords, noOfRecords,(pageNumber * size))} of {!noOfRecords}</apex:outputText> <apex:commandButton styleClass="metro" 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>
Best Answer chosen by Alex Kirby
Alex Kirby
Managed to resolve this: