You need to sign in to do that
Don't have an account?
A9865
Pick list filter on column of visual force table
I would like to filter the column "Status" of my table by selecting a value in a pick list which is integrated in the column header:
How would I modify my code?
<table class="list" border="0" cellpadding="0" cellspacing="0" id="maintable"> <thead class="rich-table-thead"> <tr class="headerRow"> <th class="headerRow"> Name</th> <th class="headerRow">Status <apex:selectList id="searchStatus" value="{!selectedStatus}" size="1" onchange="getlistDevRequests"> <apex:selectOptions value="{!Status}" /> </apex:selectList></th> <th class="headerRow">Start Date</th> </tr> </thead> <apex:repeat value="{!lstDevRequests}" var="item"> <tbody> <tr class="dataRow"> <td>{!item.Name}</td> <td><span class="status" >{!item.Status__c}</span></td> <td><apex:outputText value="{0,date,MM/dd/yyyy}"> <apex:param value="{!item.Start_Date__c}" /> </apex:outputText></td> </tr> </tbody> </apex:repeat> </table>
public with sharing class tableDevRequests { List<Dev_Request__c> lstDevRequests; public String selectedStatus{get;set;} public tableDevRequests() { } public List<SelectOption> getStatus() { List<SelectOption> statOptions= new List<SelectOption>(); statOptions.add( new SelectOption('-1','--All Status--')); for( Dev_Request__c dev : [select Id,Status__c from Dev_Request__c ] ) { statOptions.add( new SelectOption(dev.Id,dev.Status__c)); /*SelectOption list takes two parameters one is value and other one is label .In this case account name as a label and Id is the value .*/ } return statOptions; } public List<Dev_Request__c> getlstDevRequests() { if(lstDevRequests == null) lstDevRequests = [Select Id, Name, Assignee__c, Assignee__r.Name, Start_Date__c, Due_Date_QA__c, Estimated_Hours__c, Estimated_Completion_Date__c, Status__c, Overview__c, Parent_Dev_Request__c, (SELECT Id, WhatId, ActivityDAte, Owner.Name, Description, Status, Subject from Tasks) from Dev_Request__c]; return lstDevRequests; } }
How would I modify my code?