TV-C-1-5
TV-C-1-5

Reputation: 714

listMonth - I need a method that will display all days of the month - even if there are no events for a day

How can I force the listMonth view to show all days of the month and pass a custom text to each day rendered?

I would like to use something like dayRender to pass the values to each day rendered using dayRender -

dayRender: function (date, cell){
    cell.html("My custom text");
}

But dayRender does not seem to work with the listMonth view.

Upvotes: 0

Views: 391

Answers (1)

TV-C-1-5
TV-C-1-5

Reputation: 714

You can simply generate an array that contains all of the days in-between the selected date listMonth view, to force FullCalendar to show all calendar days:

$start_date = $this->input->post('start');// or however you are getting the start date
$end_date = $this->input->post('end');// or however you are getting the end date

$date_span_Array = array();// init
$temp_Array = array();// init

        while(strtotime($start_date) <= strtotime($end_date)){

            $temp_Array['title'] = 'Your custom title';
            $temp_Array['start'] = $start_date;
            $temp_Array['allDay'] = 'true';
            $temp_Array['My_Custom_Value_Or_Text'] = 'My Text';

            array_push($date_span_Array, $temp_Array);

            $start_date = date ("Y-m-d", strtotime("+1 days", strtotime($start_date)));

        }

        // array of events that span all days between 2 dates for fullCalendar selected view
        echo json_encode($date_span_Array);

You can add your own custom data, or actual event data in the creation of that array - as seen above - or afterwards during eventRender

Upvotes: 0

Related Questions