jQWidgets Forums
jQuery UI Widgets › Forums › Scheduler › selected date in calendar dateChange
This topic contains 6 replies, has 4 voices, and was last updated by admin 6 years, 7 months ago.
-
Author
-
Hi,
When the source property is set in the dateChange event the correct data is displayed in the schedule, but the selected date in the calendar jumps back to today.
$("#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 AdapterSchedulePersons = GetAppointments(); $("#SchedulePersons").jqxScheduler({ source: AdapterSchedulePersons }); });
function GetAppointments() { var Datafields = [ { name: 'PlanningId', type: 'string' }, { name: 'Description', type: 'string' }, { name: 'Location', type: 'string' }, { name: 'Opdrachtbon', type: 'int' }, { name: 'Subject', type: 'string' }, { name: 'UserNaam', type: 'string' }, { name: 'Start', type: 'date' }, { name: 'End', type: 'date' }, { name: 'Kleur', type: 'string' }, { name: 'Source', type: 'string' }, { name: 'Readonly', type: 'bool' }, { name: 'resizable', type: 'bool' }, { name: 'draggable', type: 'bool' } ] var SourceAppointments = { type: 'GET', contentType: 'application/json; charset=utf-8', datatype: 'json', id: 'PlanningId', datafields: Datafields, url: 'getData.asmx/GetPlanning', async: false, beforeprocessing: function (data) { var returnData = {}; data = data.d; totalrecords = data.count; returnData.totalrecords = data.count; returnData.records = data.data; return returnData; }, formatdata: function (data) { var view = $("#SchedulePersons").jqxScheduler('view'); var date = $("#SchedulePersons").jqxScheduler('date'); var StartDate = new Date(); var EndDate = new Date(); if (typeof (ScheduleFrom) != 'undefined') dateFrom = ScheduleFrom else dateFrom = convertdate(StartDate.setDate(1 - 7), 'shortUS'); if (typeof (ScheduleTo) != 'undefined') dateTo = ScheduleTo else dateTo = convertdate(EndDate.setDate(30 + 14), 'shortUS'); data.filterscount = "3" data.groupscount = "0" data.pagenum = "1" data.pagesize = "1000" data.sortdatafield = "Start" data.sortorder = "asc" data.filtervalue0 = "0" data.filtercondition0 = "EQUAL" data.filteroperator0 = "1" data.filterdatafield0 = "Historisch" data.filtervalue1 = dateFrom, data.filtercondition1 = "GREATER_THAN_OR_EQUAL" data.filteroperator1 = "1" data.filterdatafield1 = "End" data.filtervalue2 = dateTo data.filtercondition2 = "LESS_THAN_OR_EQUAL" data.filteroperator2 = "0" data.filterdatafield2 = "Start" formatedData = buildQueryString(data); return formatedData; } } var AdapterAppointments = new $.jqx.dataAdapter(SourceAppointments, { contentType: 'application/json; charset=utf-8', downloadComplete: function (data, textStatus, jqXHR) { return data; }, loadError: function (xhr, status, error) { BuildErrorWindow(xhr.responseText); } }); return AdapterAppointments; }
Hi hf,
Changing the source re-renders the scheduler, the views and the scheduler appointments. You may need to set the “date”, too in order to navigate.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comWhen I set the date property after changing the source, the selected date in the calendar still jumps back to the date of today.
$("#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 AdapterSchedulePersons = GetAppointments(); $("#SchedulePersons").jqxScheduler({ source: AdapterSchedulePersons }); $("#SchedulePersons").jqxScheduler({ date: new $.jqx.date(from) }); });
Hi hf,
I do not think that setting it in that event handler is a very good idea, because it will raise exactly the same event again and you will loop again.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
I need to refresh the data in the scheduler after selecting a date or navigate with the calendar in the toolbar. How can I accomplish this without having the calendar jump back to todays date?
I am finding that when you change from Week view to Month view, it will change it something random instead of the month you were originally in.
If you don’t set the date in the view change where do you set it?If the current selected Date is 7th December, the Day View displays 7th December, Week View displays 3-10 i.e selected date is in the middle and month view displays 26 november to 6 january i.e current month – December and the other month dates from november and january. Hope this explanation helps.
-
AuthorPosts
You must be logged in to reply to this topic.