You need to sign in to do that
Don't have an account?
Mahendiran Jayavarma
Filter records using dropdown list in Pageblocktable
Hi,
Please guide me for filtering records in pageblocktable using dropdonlist.
I tried to implement using following code. But I could not implement. So Please help me.
Controller:
public class ActivityController
{
public PageReference Search() {
return null;
}
Task Task;
public Task getTask() {
if(Task == null) Task = new Task ();
return Task ;
}
Public Task[] getActivities()
{
return [Select id, subject,activitydate,owner.name,pro__Billable_Hrs__c,pro__Rate_Hrs__c,pro__Billable_Amount__c from Task];
}
}
Apex page:
<apex:page controller="ActivityController" > <apex:sectionHeader title="Invoice Generate" /> <apex:form > <apex:pageBlock > <apex:pageBlockSection title="Search Task" columns="4" > <apex:inputField id="Taskstatus" value="{!Task.status}" style="width:150px;"/> <apex:commandButton value="Search" action="{!Search}"/> </apex:pageBlockSection> <apex:pageBlockSection title="Search Result" columns="1" > <apex:pageBlockTable value="{!Activities}" var="a" width="750"> <apex:column > <apex:facet name="header">Select</apex:facet> <apex:inputCheckbox value="{!a.Id}" /> </apex:column> <apex:column value="{!a.subject}" rendered="true"/> <apex:column value="{!a.owner.name}"/> <apex:column value="{!a.Billable_Hrs__c}"/> <apex:column value="{!a.Rate_Hrs__c}"/> <apex:column value="{!a.Billable_Amount__c}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock></apex:form> </apex:page>
Help me asp.
Thanks,
Mahendiran
Hi Mahendiran,
I would suggest you to use a custom picklist instead of using standard piclikst.
================= VF Page==============================
<apex:selectList size="1" id="txtStatus" value="{!strTaskStatus}">
<apex:selectOptions value="{!TaskStatus}"/>
</apex:selectList>
===================== end VF page=======================
==============Apex Controller=============================
public String strTaskStatus{get;set;}
public List<SelectOption> getTaskStatus(){
Schema.DescribeFieldResult F = Task.Status.getDescribe();
List<Schema.PicklistEntry> P = F.getPicklistValues();
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('','--All--'));
for(Integer i = 0; i < P.size(); i++){
options.add(new SelectOption(P[i].getValue(), P[i].getLabel()));
}
return options;
}
IN your pageBlock method
Public Task[] getActivities()
{
return [Select id,subject,activitydate,owner.name,pro__Billable_Hrs__c,pro__Rate_Hrs__c,pro__Billable_Amount__c from Task where Status =: strTaskStatus ];
}
=======================================================
Hope this works for you.
Hi rmeh,
Thanks for your help.
But I tried to implement custom picklist in my page.
But Im getting error for "Error: Compile Error: Method does not exist or incorrect signature: [String].getDescribe()"
Please give me solution.
Thanks,
Mahendiran
Hi,
Have you exactly done the way i have posted.
As i tested the same in my org and it is working fine.
Could you post what changes have you made to your code?
VF page:
controller:
now I done my task used by standard piclikst.
I can able to filter my records using standard piclikst.
Thanks,
Mahendiran.