Client side firstDayStart() not working with webservice

3 posts, 0 answers
  1. Ramin
    Ramin avatar
    9 posts
    Member since:
    Mar 2012

    Posted 19 Oct 2012 Link to this post

    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. Ramin
    Ramin avatar
    9 posts
    Member since:
    Mar 2012

    Posted 19 Oct 2012 Link to this post

    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.
  3. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2035 posts

    Posted 24 Oct 2012 Link to this post

    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.
Back to Top