How to make full calendar month and year in dropdo

2020-07-23 05:51发布

问题:

I have a full calendar and I need to show its month and year in dropdown list, I know this question is already asked but still not answered there. I am new to full calendar and as per as i know it is updated now hope there is some easiest way to achieve rather than giving it gotodate option. I have created code pen for the calendar if anyone has done this before then please update my codepen and give me link thank you so much... demoToEdit Below is my code I have added some of the functions of full calendar as you see I am not able to get on which event I should right dropdown year and month so I have not done it.

$(window).load(function(){

  $('#calendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },
    editable: true,
    eventRender: function(event, element, view) {
        for (var i = 0; i<= event.products.length - 1; i++) {
            element.append('<span>'+event.products[i].name+'<span>');    
        };

    },

    events: [
                {
                    title: 'EventName',
                    start: '2016-05-02',
                    products:[
                                {

                                    name:'ProductName'
                                }
                            ]
                },
                {
                    title: 'Event',
                    start: '2016-05-03',
                    products:[
                                {

                                    name:'ProductName1'
                                },
                                {

                                    name:'ProductName2'
                                },
                                {

                                    name:'ProductName3'
                                },
                            ]
                },
                {
                    title: 'EventName',
                    start: '2016-05-13',
                    products:[
                                {

                                    name:'ProductName1'
                                },
                                {

                                    name:'ProductName2'
                                }
                            ]
                },
                {
                    title: 'Event',
                    start: '2016-05-15',
                    products:[
                                {

                                    name:'ProductName'
                                }
                            ]
                },
                {
                    title: 'EventNAme',
                    start: '2016-05-21',
                    products:[
                                {

                                    name:'ProductName1'
                                },
                                {

                                    name:'ProductName2'
                                }
                            ]
                },
                {
                    title: 'Event',
                    start: '2016-05-23',
                    products:[
                                {

                                    name:'ProductName1'
                                },
                                {

                                    name:'ProductName2'
                                }
                            ]
                },
                {
                    title: 'Eventname',
                    start: '2016-05-25',
                    products:[
                                {

                                    name:'ProductName'
                                }
                            ]
                },
                {
                    title: 'Event',
                    start: '2016-05-29',
                    products:[
                                {

                                    name:'ProductName'
                                }
                            ]
                }
            ],
            dayClick: function(date, allDay, jsEvent, view) {
           console.log('date'+date.format('DD/MMM/YYYY')+"allDay"+allDay.title+"jsEvent"+jsEvent+"view"+view)
    }


}); 
})



[1]: http://codepen.io/sud/pen/LNvZmv

回答1:

It is hard to insert drop downs using fullcalendar custom buttons. I simply make header option to false and created custom header myself. Then you can insert any thing to header part and bind events to those buttons and call appropriate fullcalendar function. example functions that available are

prev (), next (), prevYear (), nextYear (), today (), gotoDate ()