jQuery UI Widgets Forums Scheduler Rebind data > selected date today

This topic contains 10 replies, has 3 voices, and was last updated by  hf 7 years, 8 months ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
  • Rebind data > selected date today #90489

    hf
    Participant

    I would like to refresh the schedules (remote) data when the dateChange event is fired (so I don’t need to call all data at once). Because there’s no refresh method, it could be achieved by setting the source again (http://www.jqwidgets.com/community/topic/refresh-schedule/#post-79630).

    This works fine, but the selected date in the calendar jumps back to todays date.

    
        $("#SchedulePersons").on('dateChange', function (event) {
                var args = event.args;
                var date = args.date;
                var from = args.from;
                var to = args.to;
    
                ScheduleFrom = new $.jqx.date(from).toString();
                ScheduleTo = new $.jqx.date(to).toString();
    
                var ShowAll = (getCookie('ShowAll') == "true");
                var AdapterSchedulePersons = GetAppointments(ShowAll);
                $("#SchedulePersons").jqxScheduler({
                    source: AdapterSchedulePersons
                });
        }
    

    I tried to set the calendars date manually after setting the source, but that didn’t worked out.

    
                var CalendarId = $("[id^=calendarjqxWidget]")[0].id;
                $("#" + CalendarId).jqxCalendar('setDate', new Date(2017, 5, 10));
    
    Rebind data > selected date today #90524

    Hristo
    Participant

    Hello hf,

    Could you try on this way:

    $("#scheduler").jqxScheduler({
    	date: new $.jqx.date(yyyy, MM, dd)
    })

    Hope this help.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    Rebind data > selected date today #90533

    hf
    Participant

    Hi Hristo,

    It doesn’t make a difference.

    
    $("#SchedulePersons").on('dateChange', function (event) {
                // is not functioning correct in IE; mixes end and start.
                var args = event.args;
                var date = args.date;
                var from = args.from;
                var to = args.to;
    
                ScheduleFrom = new $.jqx.date(from).toString();
                ScheduleTo = new $.jqx.date(to).toString();
    
                var ShowAll = (getCookie('ShowAll') == "true");
                var AdapterSchedulePersons = GetAppointments(ShowAll);
                $("#SchedulePersons").jqxScheduler({
                    source: AdapterSchedulePersons
                });
    
                $("#SchedulePersons").jqxScheduler({
                    date: date
                })
    
            });
    

    By the way.. I was expecting by setting the date property in the dateChange event would cause a never ending loop, but it didn’t.

    Rebind data > selected date today #90534

    Peter Stoev
    Keymaster

    Hey hf, just an idea, bind to the bindingComplete event of the Scheduler and set the current date there.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Rebind data > selected date today #90540

    hf
    Participant

    Hi Peter,

    Same result.. Shows the correct data in the schedule and displays the correct date above the schedule but still todays date selected in the calendar.

    The awkward thing about this, that when I want to go back to todays date.. I can’t select it in the calendar cause it’s already selected.

    
            $('#SchedulePersons').on('bindingComplete', function (event) {
    
                $("#SchedulePersons").jqxScheduler({
    	            date: new $.jqx.date(2017, 1, 11)
                })
    
            });
    
    Rebind data > selected date today #90541

    Peter Stoev
    Keymaster

    Hi hf,

    Setting the Scheduler’s date property navigates the Scheduler view and does not affect the calendar in the toolbar.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Rebind data > selected date today #90544

    hf
    Participant

    Hi Peter,

    So when I use the calendar or the next/prev buttons it affects the calendar AND the schedule. But when I set the date property it only affects the schedule. Would it not be more logical, that the date is selected when navigating through the scheduler?

    Is there another way to set the selected date in the calendar on dateChange?

    Rebind data > selected date today #90545

    Peter Stoev
    Keymaster

    Hi hf,

    Yes, it would be more logical to have this behavior in the Scheduler. As a workaround with a non-public/internal API, use the navigateTo method and pass a jqx.date object to it.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Rebind data > selected date today #90556

    hf
    Participant

    Hi Peter,

    Thanks for your quick response. The navigateTo method triggers the dateChange so I can’t use the method in dateChange and bindingComplete events, because that causes an endless loop..

    Rebind data > selected date today #90557

    Peter Stoev
    Keymaster

    Hi hf,

    I see no problem to use it inside the bindingComplete and of course it will trigger dateChange. If necessary, you can use boolean flags.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Rebind data > selected date today #90714

    hf
    Participant

    Indeed, only a matter of boolean 🙂 Thnx, works like a charm!

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.