gpt4 book ai didi

javascript - dhtmlx 时间线跳过几周而不是跳过周末到星期一

转载 作者:行者123 更新时间:2023-12-03 10:34:25 27 4
gpt4 key购买 nike

我的 dhtmlx 时间线不断跳过几周,而不是从周末跳到星期一。我不明白它为什么这样做。我添加了一些应该可以解决此问题的代码,但事实并非如此!

#

到目前为止,当我点击转到下周时,它会一次跳过多个星期 - 例如:将从 6 月 6 日一直到 6 月 18 日!它在整个程序中一直这样做。

我正在尝试显示以下日期+时间结构

周一至周五,9 - 17:30

Javascript

<script type="text/javascript" charset="utf-8">

function init() {

scheduler.locale.labels.timeline_tab = "Timeline";
scheduler.locale.labels.section_custom="Section";
scheduler.config.details_on_create=true;
scheduler.config.details_on_dblclick=true;
scheduler.config.xml_date="%Y-%m-%d %H:%i";

//===============
//Configuration
//===============
var sections=[
{key:1, label:"James Smith"},
{key:2, label:"John Williams"},
{key:3, label:"David Miller"},
{key:4, label:"Linda Brown"}
];

scheduler.createTimelineView({
name: "timeline",
x_unit: "hour",
x_date: "%H:%i",
x_step: 0.5*2,
x_size: 228/2,// 5 day
y_unit: sections,
y_property: "section_id",
render:"bar",
second_scale:{
x_unit: "day", // unit which should be used for second scale
x_date: "%F %d" // date format which should be used for second scale, "July 01"
}
});

//Skip the weekend.
scheduler.ignore_month = function(date){


// 0 refers to Sunday, 6 - to Saturday
// scheduler.ignore_timeline = function(date){
// if(date.getHours() < 9 || date.getHours() >= 18)
// return true;
// if (date.getDay() == 6 || date.getDay() == 0) //hides Saturdays and Sundays
// return true;
// };

scheduler.attachEvent("onBeforeViewChange", function(old_mode,old_date,mode,date){
if(old_date == undefined)
return true;
else{
var new_date = old_date;
if(old_date < date)
new_date.setDate(old_date.getDate()-7);
else
new_date.setDate(old_date.getDate()+7);


updateView();
return false;
}
});
function updateView(){
setTimeout(function(){
scheduler.updateView( new Date(2015,6,6) );
}, 1000);
}
scheduler.attachEvent("onEventAdded", function(event_id,e){
var event = this.getEvent(event_id)
var day = event.start_date.getDay();
if(day==6 || day==0) this.deleteEvent(event_id)
});
// 0 refers to Sunday, 6 - to Saturday
scheduler.ignore_week = function(date){
if (date.getDay() == 6 || date.getDay() == 0) //hides Saturdays and Sundays
return true;

};
//updateView();
// setTimeout(function(){
// scheduler.updateView( new Date(2015,6,6) );
// }, 1000);


//===============
//Data loading
//===============

scheduler.config.lightbox.sections=[
{name:"description", height:130, map_to:"text", type:"textarea" , focus:true},
{name:"custom", height:23, type:"select", options:sections, map_to:"section_id" },
{name:"time", height:72, type:"time", map_to:"auto"}
];
if (date.getDay() == 6 || date.getDay() == 0) //hides Saturdays and Sundays
return true;
};
scheduler.init('scheduler_here',new Date(2015,5,29),"timeline");
scheduler.parse([
{ start_date: "2015-06-30 09:00", end_date: "2015-07-01 12:00", text:"Task A-12458", section_id:1},
{ start_date: "2015-06-30 10:00", end_date: "2015-06-30 21:00", text:"Task A-89411", section_id:1},
{ start_date: "2015-06-30 10:00", end_date: "2015-07-01 14:00", text:"Task A-64168", section_id:1},
{ start_date: "2015-06-30 16:00", end_date: "2015-07-02 17:00", text:"Task A-46598", section_id:1},

{ start_date: "2015-06-30 12:00", end_date: "2015-07-02 20:00", text:"Task B-48865", section_id:2},
{ start_date: "2015-06-30 14:00", end_date: "2015-06-30 18:00", text:"Task B-44864", section_id:2},
{ start_date: "2015-06-30 16:30", end_date: "2015-07-01 18:00", text:"Task B-46558", section_id:2},
{ start_date: "2015-06-30 18:30", end_date: "2015-07-01 00:00", text:"Task B-45564", section_id:2},

{ start_date: "2015-06-30 08:00", end_date: "2015-07-01 12:00", text:"Task C-32421", section_id:3},
{ start_date: "2015-07-01 14:30", end_date: "2015-07-02 16:45", text:"Task C-14244", section_id:3},

{ start_date: "2015-07-01 09:20", end_date: "2015-07-01 18:20", text:"Task D-52688", section_id:4},
{ start_date: "2015-06-30 11:40", end_date: "2015-06-30 21:30", text:"Task D-46588", section_id:4},
{ start_date: "2015-07-01 12:00", end_date: "2015-07-02 18:00", text:"Task D-12458", section_id:4}
],"json");
}


</script>
</head>

HTML

<body onload="init();">
<div id="scheduler_here" class="dhx_cal_container" style='width:100%; height:100%;'>
<div class="dhx_cal_navline">
<div class="dhx_cal_prev_button">&nbsp;</div>
<div class="dhx_cal_next_button">&nbsp;</div>
<div class="dhx_cal_today_button"></div>
<div class="dhx_cal_date"></div>
<div class="dhx_cal_tab" name="day_tab" style="right:204px;"></div>
<div class="dhx_cal_tab" name="week_tab" style="right:140px;"></div>
<div class="dhx_cal_tab" name="timeline_tab" style="right:280px;"></div>
<div class="dhx_cal_tab" name="month_tab" style="right:76px;"></div>
</div>
<div class="dhx_cal_header">
</div>
<div class="dhx_cal_data">
</div>
</div>
</body>

最佳答案

请在这里找到您问题的答复:http://forum.dhtmlx.com/viewtopic.php?f=6&t=39524

关于javascript - dhtmlx 时间线跳过几周而不是跳过周末到星期一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29069894/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com