I tried to integrate a filter in the column "Status" of my Visualforce table. However, I can see the header now, but the table does not return any results for the body. I think it has to do with the declaration of methods and variables.
<apex:page Controller="tableDevRequests">
<apex:form id="form">
<apex:pageblock >
<apex:pageMessages />
<apex:outputpanel rendered="{!editTable==false && generateTask==false && editTask==false}">
<table class="list" border="0" cellpadding="0" cellspacing="0" id="maintable">
<thead class="rich-table-thead">
<tr class="headerRow">
<th class="headerRow">Dev Request Name</th>
<th class="headerRow">Status
<apex:selectList id="searchStatus" value="{!selectedStatus}" size="1">
<apex:selectOptions value="{!Status}" id="field"/>
<!--<apex:actionSupport event="onclick" reRender="tableData" action="{!getlstDevRequests}"/>-->
<apex:actionSupport event="onclick" reRender="tableData" action="{!getlstDevRequests_edit}"/>
</apex:selectList>
</th>
<th class="headerRow">Start Date</th>
</tr>
</thead>
<apex:outputPanel id="tableData">
<apex:repeat value="{!lstDevRequests_edit}" var="item">
<tbody>
<tr class="dataRow">
<td bgcolor="#faffff" height="50">{!item.Name}</td>
<td class="statusCol" bgcolor="#faffff" height="50">{!item.Status__c}</td>
<td bgcolor="#faffff" height="50"><apex:outputText value="{0,date,MM/dd/yyyy}"> <apex:param value="{!item.Start_Date__c}" /> </apex:outputText></td>
</tr>
</tbody>
</apex:repeat>
</apex:outputPanel>
</table>
</apex:outputpanel>
</apex:pageblock>
</apex:form>
</apex:page
Controller:
public with sharing class tableDevRequests {
public String selectedStatus{get;set;}
public List<Dev_Request__c> lstDevRequests_edit {get; set;}
public Task insertnewTask {get;set;}
public boolean editTable {get;set;}
public boolean generateTask {get;set;}
public boolean editTask {get;set;}
public boolean deleteTask {get;set;}
public Id selectedItemId { get; set; }
public tableDevRequests() {
editTable = false;
generateTask = false;
editTask = false;
lstDevRequests_edit = getlstDevRequests_edit();
selectedStatus = '-1';
}
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_edit() {
if(selectedStatus =='-1') {
lstDevRequests_edit = [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];
}
else {
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
WHERE Status__c =:selectedStatus];
}
return null;
}
}
As I now have looked into it, it may have to do with the declaration of lstDevRequests_edit, I am not sure if and where to use a getter method and if this collides with the list declaration.
Thank you for your help!
Well, after playing with it further and declaring the initial list in a different method, after changing the status the list appears on top above the table. It seems there is a combination with method and rendering that does not function.
onchange
instead ofonclick