0

I am using jquery fullcalendar to display records in calendar view. Currently i have a scenario where i am selecting months from vf page and i need to fetch records from controller for the selected month only.

The below javascript is giving me the start date of the month selected.

var month = $('#calendar').fullCalendar('getDate');
var f = month.format('YYYY-MM-01');

Ex - if i select Oct 2016, it gives as 2016-10-01

I need to pass this info from vf page to controller and i need to add this in my SOQL filter.

SOQL -

eventList = [select Id, Name, Start_Date__c,  End_Date__c   from ABC__c ]; 

In ABC__c object i have startdate & enddate as Date field which can be any date.

How to fit the selected month from vf page to this SOQL .

Regards

1 Answer 1

0

you can use apex:actionfunction with apex:param to pass the value

<script>
callactfunc(f);
</script>

Then an actionfunction

<apex:actionfunction action="{!controllermethod} name="callactfunc" rerender="form">
      <apex:param name="datename" value="" />
</apex:actionfunction>

And finally in your controller

public void controllermethod(){
string datevar = ApexPages.currentPage().getParameters().get('datename');
//... continue with processing

}
6
  • Hi Tushar.. Thanks for the help.. But how to design my soql as i have only startdate and enddate .. do i need to create another field..as string datevar will always have start date of every month .. Commented Nov 30, 2016 at 4:45
  • @learningmode you can createdynamic SOQl here. like ` WHERE Start_Date__c <=: stDate AND End_Date__c >=: stDate ]` where stdate = date.valueof(datevar) Commented Nov 30, 2016 at 5:15
  • stdate is a string variable? Commented Nov 30, 2016 at 9:57
  • @learningmode nope date type. Commented Nov 30, 2016 at 9:58
  • I have wriiten like 'Date stdate = date.valueof(datevar);' i am getting error 'Argument cannot be null'. Commented Nov 30, 2016 at 10:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .