This is a migrated thread and some comments may be shown as answers.

Client side firstDayStart() not working with webservice

2 Answers 36 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Ramin
Top achievements
Rank 1
Ramin asked on 19 Oct 2012, 03:20 PM

onclientRequestSuccess does not seem to have the updated firstDayStart().  I thought I had figured it out, but its not working:

As I navigate in the calendar, changing months, it does not reflect the right day - what am I doing wrong?

function onClientRequestSuccess(scheduler, eventArgs) {
    if (typeof loadList == 'function') {
        var start = scheduler.get_firstDayStart();
        var end = start;
        var curView = scheduler.get_selectedView();
        if (curView == 0) {  // day view
            end.setHours(start.getHours() + 24);
        } else if (curView == 1) {  // week view
            end.setHours(start.getHours() + (24 * 7));
        } else if (curView == 2) {  // week view
            end.setMonth(start.getMonth() + 1);
            // need to find out if we are on a Saturday..  If not, we need to add days until we get there
        }
        alert(start + " **- " + end);
        loadList(start.getTime(), end);
    }
}

2 Answers, 1 is accepted

Sort by
0
Ramin
Top achievements
Rank 1
answered on 19 Oct 2012, 03:41 PM
Yes, I realize theres a bug there..  I shouldnt be programming at 7am - need coffee.. 
var end = start should read:
var end = new Date(start);

still have the same issue..  The date doesnt seem to get updated as i navigate around.
0
Boyan Dimitrov
Telerik team
answered on 24 Oct 2012, 07:01 AM
Hello Loren,

Please try this approach to achieve the described scenario:

function onClientRequestSuccess(scheduler, eventArgs) {   
                var start = scheduler.get_firstDayStart();
                var end = new Date(start.getFullYear(), start.getMonth(), start.getDate());
                var curView = scheduler.get_selectedView();
                if (curView == 0) {  // day view
                    end.setHours(start.getHours() + 24);
                } else if (curView == 1) {  // week view
                    end.setHours(start.getHours() + (24 * 7));
                } else if (curView == 2) {  // month view
                    end.setMonth(start.getMonth() + 1);
                       // need to find out if we are on a Saturday..  If not, we need to add days until we get there
                    var daysToSaturday = Math.abs(end.getDay() - 6);
                    end.setDate(end.getDate() + daysToSaturday);
                }
                alert(start + " **- " + end);

You can find more information about .getDay() method here.

Hope that this will lead you into right direction.

Regards,
Boyan Dimitrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Scheduler
Asked by
Ramin
Top achievements
Rank 1
Answers by
Ramin
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or