核心提示:Devextreme Scheduler 扩展拖动选择时间功能(代码教程)data: meeting(会议)resourcesData: resource(如房间)date: scheduler选择的...
Devextreme Scheduler 扩展拖动选择时间功能(代码教程)
data: meeting(会议) resourcesData: resource(如房间) date: scheduler选择的时间 var scheduler = { Set: function (data, resourcesData, date) { var Dates = []; var downHandler = function (e) { var el = $(e.target); if (el.hasClass("dx-scheduler-date-table-cell")) { startData = el.data().dxCellData; isSelectionStarted = true; target = e.target; setCookie("ResourceId", startData.groups.ResourceId); } } var upHandler = function (e) { e.cancel = true; var el = $(e.target); if (el.hasClass("dx-scheduler-date-table-cell") && target !== e.target) { if (isSelectionStarted) { Dates.length = 0; Dates.push(startData.startDate); Dates.push(startData.endDate); Dates.push(el.data().dxCellData.startDate); Dates.push(el.data().dxCellData.endDate); result = sort(Dates); console.log(result); DragStime = convertTime(result[0][0], "all"); DragEnd = convertTime(result[0][3], "all"); } } isSelectionStarted = false; target = null; startData = null; } $("#scheduler").dxScheduler({ dataSource: data, views: ["timelineMonth"], currentView: "timelineMonth", currentDate: date, firstDayOfWeek: 0, cellDuration: 60, crossScrollingEnabled: true, groups: ['ResourceId'], resources: [{ fieldExpr: "ResourceId", allowMultiple: true, dataSource: resourcesData, }], editing: { allowAdding: false, allowUpdating: false, allowDeleting: false, allowDragging: false, allowEditing: false, }, onCellClick: function (e) { e.cancel = true; $('#myModal').modal('show') }, onAppointmentDblClick: function (e) { e.cancel = true; //$('#myModal').modal('show') }, onAppointmentFormCreated: function (e) { e.cancel = true; }, onAppointmentClick: function (e) { e.cancel = true; }, height: 580, onContentReady: function (arg) { $(arg.element).off("dxpointerdown", downHandler); $(arg.element).off("dxpointerup", upHandler); $(arg.element).on("dxpointerdown", downHandler); $(arg.element).on("dxpointerup", upHandler); //arg.element.find(".dx-scheduler-date-table-cell").mousemove(function (arg) { //console.log($(arg.target).data("dxCellData")); //});鼠标滑过捕捉对应数据 //document.getElementsByClassName('dx-scrollable-scroll-content').scrollLeft = 0; //console.log($("p.dx-scrollable-scroll.dx-state-invisible")); }, }); } }