2

I have an ASP.NET web application in c#.

I'm using fullCalendar control in my aspx page. Where I already selected some dates and stored in the DataBase.

Now, I have fetched those dates, but want to display them as selected in the FullCalendar control.

Can any one Please help me, how to bind number of Dates in FullCalendar.

I have tried this code:

<script>
    $("#calendar").fullCalendar('select', '2016-09-05', '2016-09-21');
</script>

But this one is, just hightlighting and when I select any other date, all these dates are disappearing.

And in the database I have different dates, like: "2016-09-05,2016-09-07,2016-09-08,2016-09-11,2016-09-15,2016-09-17"

I want to select these dates, programmatically.

Please help me guys.

Thanks

user2164172
  • 27
  • 1
  • 7

1 Answers1

0

The select method is for selecting a period of time (in order to create a new event) - not for selecting existing events. see https://fullcalendar.io/docs/selection/select_method/

In fact, fullCalendar doesn't really have any concept of an event being "selected". The closest thing is the "eventClick" event, which you can handle when a user clicks on an event. But it's a transient thing, it doesn't result in any kind of state being stored which would indicate selection of the event.

I think if you want some/all of your events to be pre-selected when the calendar loads, your best option is probably to loop through the events, find the ones you want, and add some sort of CSS class/style to the event's div which will indicate to the user that it's selected, and maintain a variable (either within the event object, or in a separate list) to indicate its current state.

If you wanted to make them selectable/un-selectable during usage, you could handle the eventClick event and put some similar code in there to check the event's current state and select/un-select it accordingly.

ADyson
  • 57,178
  • 14
  • 51
  • 63