[FullCalendar 2] how to get current view in the fullcalendar2

Forge Component
(31)
Published on 2019-03-29 by Daniel Filipe
31 votes
Published on 2019-03-29 by Daniel Filipe

Hi

I am trying to get the current view of the fullcalendar.

in the javascript I have given code as


"var view = FullCalendar('getView');
alert(view.title);"


but its giving the error like "
An exception occurred in the client script. Error: FullCalendar is not a function".

can anyone help on this.

Thanks

Srinivas Nalamati

Hi Srinivas,

I think it needs to be fullCalendar (staring with lower character f).

JavaScript is case sensitive.

Regards,

Daniel

Daniël Kuhlmann wrote:

Hi Srinivas,

I think it needs to be fullCalendar (staring with lower character f).

JavaScript is case sensitive.

Regards,

Daniel

Hi Danier,

I tried with the small letter also. I am getting the following error


"An exception occurred in the client script. Error: fullCalendar is not defined"


Thanks

Srinivas Nalamati


Hi Srinivas,


Try this:


OSFullCalendarInstance.calendar.view.type

Daniel Filipe wrote:

Hi Srinivas,


Try this:


OSFullCalendarInstance.calendar.view.type

Hi Daniel,

this works for me. Thank you.

now can I set this view name to "defaultview" or is there any attribute like to change the view through this java script.

My problem is

when I perform some action in the week/day view , after refresh the page goes to the month view as I set defaultview as month view.

now I am trying to get the viewname from the dayview/weekview and then I am trying to set that view name to default view. so to keep the current view after refresh.

any suggestions on this

Thanks

Srinivas Nalamati


Daniel Filipe wrote:

Hi Srinivas,


Try this:


OSFullCalendarInstance.calendar.view.type

Hi Daniel,

this works for me. Thank you.

now can I set this view name to "defaultview" or is there any attribute like to change the view through this java script.

My problem is

when I perform some action in the week/day view , after refresh the page goes to the month view as I set defaultview as month view.

now I am trying to get the viewname from the dayview/weekview and then I am trying to set that view name to default view. so to keep the current view after refresh.

any suggestions on this

Thanks

Srinivas Nalamati


in the advancedconfig of fullcalendar my javascript code is


defaultView: (OSFullCalendarInstance.calendar.view.type !== null ? OSFullCalendarInstance.calendar.view.type : 'dayGridMonth'),

But this is not working.

any other option for the above.


Thanks

Srinivas Nalamati

Hi Srinivas,

To maintain the default view state whenever the view changes (for example a day view or week view or month view is clicked) I have added an event listener for this and storing the value of view we get in a local variable. This helps us to have the latest view in local variable whenever the view type changes. I want to see if others have any ideas. 

Gopi Nath wrote:

Hi Srinivas,

To maintain the default view state whenever the view changes (for example a day view or week view or month view is clicked) I have added an event listener for this and storing the value of view we get in a local variable. This helps us to have the latest view in local variable whenever the view type changes. I want to see if others have any ideas. 


Hi Gopinath,

the local variables/session variables are not accessible from the javascript and vice versa. in this scenario how can i retrieve the value of a local variable which is assigned in the script.

Thanks

Srinivas Nalamati