You need to sign in to do that
Don't have an account?
Laytro80
Custom List view with a dynamic search
Hi,
Struggling on this, I would like a custom list view with a dynamic date field search. Below is a visualforce page which is all set-up just how I want it. I am using the action save clearly this needs to be a search method.
<apex:page standardController="Reservation__c" extensions="Resmanager"> <apex:form > <apex:sectionHeader title="Availability Search"/> <apex:pageBlock title="Search"> <apex:pageBlockButtons > <apex:commandButton action="{save}" value="Search"/> </apex:pageBlockButtons> <apex:inputField value="{!Reservation__c.Start_Date__c}"/> </apex:pageBlock> <apex:pageBlock title="Reservations"> <apex:pageBlockSection > <apex:pageBlockTable value="{!Reservations}" var="res"> <apex:column value="{!res.Start_Date__c}" /> <apex:column value="{!res.End_Date__c}" /> <apex:column value="{!res.Nights__c}" /> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
I am not sure how to write the search method, my attempt on the controller below. I am hardcoding yesterday to get the controller to work.
public class Resmanager { public Resmanager(ApexPages.StandardController controller) { } public List<Reservation__c> getReservations(){ List<Reservation__c> listBd=[select r.id, r.Start_Date__c, R.End_Date__c, nights__c from Reservation__c r where start_date__c = yesterday]; return listBd; } }
Change line
to
All Answers
Create a getter and setter for Reservation object and initialize it with controller.
Now instead of Yesterday, you can use :
reservation.Start_Date__c.
On click of Save , you ony need to refresh the result section. This will call the reservation getter and will will display the refreshed result.
Thanks for the post.
I very new to APEX and have only had to use it couple of times.
I tried without any success to apply get and set to the code but I keep getting a ton of errors.
Are you able to provide some sample code?
No problem if not thanks for your help.
R
Use this :
Thanks for this, have tried still getting problems.
Error: Resmanager Compile Error: Illegal assignment from SObject to SOBJECT:Reservation__c at line 4 column 12
Apex Controller
Made some changes to your code highlighted in red.
Visualforce Page
Change line
to
Thanks for all your help a pleasure working with you. Got there in the end and thanks to your help I now understand how to create these types of APEX solutions.