-1

Beginner for New Calendar I want to retrieve the events from a database for the full Calendar but I want to limit or restrict the data for a specific date range that is appearing on the screen

for Retrieving events I need to pass a start date and end Date that has been selected on the screen to a generic handler i.e. NewJosn.ashx

Sample code I'm using is:

var calendar = $('#calendar').fullCalendar({
    theme: true,
    height: calHeight,
    allDaySlot: false,
    disableDragging: false,
    defaultView: 'agendaWeek',
    slotEventOverlap: false,
    slotMinutes: varTimeSlot,
    firstHour: startTimeNew,
    firstDay: varFirstDay,
    header: {
        left: '',
        center: 'prev,today,title,next',
        right: 'resourceDay,agendaWeek,month' //resourceDay
    },
    timeFormat: 'h(:mm)tt{ - h(:mm)}tt',
    axisFormat: 'h(:mm)tt',
    editable: true,
    events: 'NewJSON.ashx',
    eventDrop: eventDropped,
    eventClick: function (calEvent, jsEvent, view) {
    },
    viewDisplay: function (view) {   
    },
    eventMouseover: function (event, jsEvent, view) {
            $(jsEvent.target).attr('title', event.title);
    },
    eventMouseout: function (event, jsEvent, view) {
    },
    dayClick: function (date, allDay, jsEvent, view) {

    },
    eventAfterRender: function (event, element, view) {
    },
    resources: [
                {
                    name: 'Resource 1',
                    id: '1'
                },
                {
                    name: 'Resource 2',
                    id: '2'
                },
                {
                    name: 'Resource 3',
                    id: '3'
                },
                {
                    name: 'Resource 4',
                    id: '4'
                }
    ]
});
Draken
  • 3,134
  • 13
  • 34
  • 54
Rahul
  • 41
  • 3

1 Answers1

0

You shouldn't need to do anything really. If you're defining your events as a JSON feed, which it looks like you are, then see the docs here: http://fullcalendar.io/docs/event_data/events_json_feed/

"FullCalendar will visit the URL whenever it needs new event data. This happens when the user clicks prev/next or changes views. FullCalendar will determine the date-range it needs events for and will pass that information along in GET parameters."

So all your need to do is ensure the method in your server-side handler can receive the start and end date parameters and limit the data it returns appropriately.

ADyson
  • 57,178
  • 14
  • 51
  • 63
  • Actually its take too much time to load data and Evry time i click it goes to db and again bring all the data – Rahul Jul 11 '16 at 09:30
  • then I would guess that your server-side is not filtering the data properly. – ADyson Jul 11 '16 at 09:32
  • DateTime start = new DateTime(1970, 1, 1); DateTime end = new DateTime(1970, 1, 1); start = start.AddSeconds(double.Parse("1377973800")); end = end.AddSeconds(double.Parse("1381602600")); – Rahul Jul 11 '16 at 09:34
  • How to get Start Date and End Date on Server Side – Rahul Jul 11 '16 at 09:34
  • They are passed as GET parameters. Looks like you've got some sort of ASHX handler. I've never used one, but there are plenty of examples of how to how to retrieve the querystring parameters on the net. I would guess that something like this would do what you need: `public void ProcessRequest (HttpContext context) { var startDate = context.Request.QueryString["start"]; var endDate = context.Request.QueryString["end"]; }` – ADyson Jul 11 '16 at 09:38
  • We dont Need to pass this parameter While calling – Rahul Jul 11 '16 at 09:41