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

New Opportunity on Home Page Visual Force
I have a piece of code that shows the user all of the opportunities assigned to them. See the apex and visualforce below. The two things I can't figure out is how to give the user the ability to filter all of the columns. Additionally i'm curious if i could have a button "New Opportunity" that would launch them to the new opportunity screen.
Apex:
Visual Force
Apex:
public with sharing class Pagination_min { Public Integer noOfRecords{get; set;} Public Integer size{get;set;} public ApexPages.StandardSetController setCon { get{ if(setCon == null){ size = 500; string OwnersId = userinfo.getUserId() ; string Rectypeid = '01240000000Uexl'; string Rectypeid2 = '01240000000cnJS'; string queryString = 'Select Name, StageName,FED__c,Broker__c,Broker_Name__c,Core_Product__c,LeadSource,Number_Quoted__c,CreatedDate FROM Opportunity Where OwnerId = :OwnersId AND IsClosed = False AND (RecordTypeId = :Rectypeid OR RecordTypeId= :RecTypeId2) order by FED__c'; setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString)); setCon.setPageSize(size); noOfRecords = setCon.getResultSize(); } return setCon; }set; } Public List<Opportunity> getOpps(){ List<Opportunity> oppList = new List<Opportunity>(); for(Opportunity o : (List<Opportunity>)setCon.getRecords()) oppList.add(o); return oppList; } public pageReference refresh() { setCon = null; getOpps(); setCon.setPageNumber(1); return null; } }
Visual Force
<apex:page controller="Pagination_min"> <apex:form > <apex:pageBlock id="pb"> <apex:pageBlockTable value="{!opps}" var="o"> <apex:column headerValue="Opportunity Name"> <apex:outputlink value="/{!o.id}" target="__blank">{!o.Name}</apex:outputlink> </apex:column> <apex:column value="{!o.StageName}"/> <apex:column value="{!o.FED__c}"/> <apex:column headerValue="Broker"> <apex:outputlink value="/{!o.Broker__c}" target="__blank">{!o.Broker_Name__c}</apex:outputlink> </apex:column> <apex:column value="{!o.Core_Product__c}"/> <apex:column value="{!o.LeadSource}"/> <apex:column value="{!o.Number_Quoted__c}"/> <apex:column value="{!o.CreatedDate}"/> </apex:pageBlockTable> <apex:panelGrid columns="7"> <apex:commandButton status="fetchStatus" reRender="pb" value="|<" action="{!setCon.first}" disabled="{!!setCon.hasPrevious}" title="First Page"/> <apex:commandButton status="fetchStatus" reRender="pb" value="<" action="{!setCon.previous}" disabled="{!!setCon.hasPrevious}" title="Previous Page"/> <apex:commandButton status="fetchStatus" reRender="pb" value=">" action="{!setCon.next}" disabled="{!!setCon.hasNext}" title="Next Page"/> <apex:commandButton status="fetchStatus" reRender="pb" value=">|" action="{!setCon.last}" disabled="{!!setCon.hasNext}" title="Last Page"/> <apex:outputText >{!(setCon.pageNumber * size)+1-size}-{!IF((setCon.pageNumber * size)>noOfRecords, noOfRecords,(setCon.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>
http://www.w3schools.com/howto/howto_js_filter_table.asp
Adapt it to use with apex:pageBlockTable (when searching for the id, use the nomenclature for apex components)
And you can add a simple html button that redirects you to the edit page of a new opportunity. Just hit "new" in the opps tab and copy the link where it redirects you (in my case: "(domain).my.salesforce.com/006/e?retURL=%2F006%2Fo") and put it in the "onclick" event for the button ( onClick="window.open((domain).my.salesforce.com/006/e?retURL=%2F006%2Fo); )
That would be the easiest way