robmonie / jquery-week-calendar

Now actively maintained in the following fork - https://github.com/themouette/jquery-week-calendar
388 stars 388 forks source link

JSON parameters start - end problem with daysToShow != 7 #19

Open Zambros opened 14 years ago

Zambros commented 14 years ago

Hi everybody I use week-calendar with daysToShow = 11, start and end parameters are setting to filter every 7 days. I tested with 2 day and everytime start and end parameters filter for 7 days.

What's it wrong? Is a bug??

Zambros commented 14 years ago

to show my example see these page: http://www.magicbussrl.it/Planning/planning_conferme.php you can change day with listbox "giorni" and "applica filtro"

Zambros commented 14 years ago

The problem is here if (typeof options.data == 'string') { if (options.loading) options.loading(true); var jsonOptions = {}; jsonOptions[options.startParam || 'start'] = Math.round(weekStartDate.getTime() / 1000); jsonOptions[options.endParam || 'end'] = Math.round(weekEndDate.getTime() / 1000); $.getJSON(options.data, jsonOptions, function(data) { self._renderEvents(data, $weekDayColumns); if (options.loading) options.loading(false); }); }

In details jsonOptions[options.endParam || 'end'] = Math.round(weekEndDate.getTime() / 1000);

So json endParam is always 7. Any suggestion? I think the true way is : jsonOptions[options.endParam || 'end'] = Math.round(weekStartDate.getTime() / 1000 + this.options.daysToShow-1 * 86400);

Zambros commented 14 years ago

Ok I see the solution:

        jsonOptions[options.endParam || 'end'] = Math.round((weekStartDate.getTime() / 1000)+((this.options.daysToShow)*86400));

I hope this is helpfull for other.