英文:
syncfusion datetimepicker I want to set default time
问题
你好,我正在使用此页面上的示例:
我的问题是,我想设置默认时间,如开始时间:9:00:00 和结束时间:9:30:00。
此外,客户可以自由设置时间...
你能帮助我吗T.T...
而且我想拖动弹出窗口...
我尝试了以下代码,但它不起作用:
function OnPopupOpen(args) {
ej.base.addClass([args.element], ['e-draggable']);
}
英文:
hello I'm using the example on this page
and my problum is that I want to set the default time
like start time : 9:00:00 and end time : 9:30:00
also, client can set time freely...
could you help me T.T ...
and also I want to drag the popup...
I tried
function OnPopupOpen(args) {
ej.base.addClass([args.element], ['e-draggable']);
this code but It doesn't work..
答案1
得分: 1
我没有找到弹出框可移动的配置。但可以观察到弹出框的ID是“schedule_dialog_wrapper”。
对于第一个问题,您可以尝试修改日期选择器部分如下:
if (!startElement.classList.contains('e-datetimepicker')) {
new ej.calendars.DateTimePicker({ value: new Date(startElement.value) || new Date(new Date(startElement.value).toISOString().split("T")[0] + "T09:00:00+08:00") }, startElement);
}
var endElement = args.element.querySelector('#EndTime');
if (!endElement.classList.contains('e-datetimepicker')) {
new ej.calendars.DateTimePicker({ value: new Date(endElement.value) || new Date(new Date(endElement.value).toISOString().split("T")[0] + "T09:30:00+08:00") }, endElement);
}
它将默认在弹出框中显示9:00-9:30(将“+03:00”更改为您的时区)。
修改说明:value: new Date(startElement.value) || xxx
这句话的意思是,如果startelement不为空,则选择前者,否则选择后者。
英文:
I didn't find the configuration of popup movable. But it can be observed that the popup id is "schedule_dialog_wrapper".
For the 1st question, you can try modify the datepicker part like below
if (!startElement.classList.contains('e-datetimepicker')) {
new ej.calendars.DateTimePicker({ value: new Date(startElement.value) || new Date(new Date(startElement.value).toISOString().split("T")[0] + "T09:00:00+08:00") }, startElement);
}
var endElement = args.element.querySelector('#EndTime');
if (!endElement.classList.contains('e-datetimepicker')) {
new ej.calendars.DateTimePicker({ value: new Date(endElement.value) || new Date(new Date(endElement.value).toISOString().split("T")[0] + "T09:30:00+08:00") }, endElement);
}
It will get 9:00-9:30 by default in popup.(change the "+03:00" to your timezone)
Modify explaination:value: new Date(startElement.value) || xxx
This sentence means if the startelement is not empty choose the front one, or will choose the latter.
答案2
得分: 1
你可以使用以下代码在编辑器模板中设置新事件弹出窗口的默认时间。
function onPopupOpen(args) {
if (args.type === 'Editor') {
if (args.target.classList.contains('e-work-cells')) {
args.data.StartTime = new Date(args.data.StartTime.setHours(9, 0, 0));
args.data.EndTime = new Date(args.data.EndTime.setHours(9, 30, 0));
}
var startElement = args.element.querySelector('#StartTime');
if (!startElement.classList.contains('e-datetimepicker')) {
new ej.calendars.DateTimePicker({ value: args.data.StartTime || new Date() }, startElement);
}
var endElement = args.element.querySelector('#EndTime');
if (!endElement.classList.contains('e-datetimepicker')) {
new ej.calendars.DateTimePicker({ value: args.data.EndTime || new Date() }, endElement);
}
}
}
关于如何拖动弹出窗口,请参考以下共享的用户指南。
function onPopupOpen(args) {
var dragElement = args.element;
var draggable = new ej.base.Draggable(dragElement, { clone: false });
}
英文:
You can set the default time for the new event popup in the editor template by using the below code.
function onPopupOpen(args) {
if (args.type === 'Editor') {
if(args.target.classList.contains('e-work-cells')) {
args.data.StartTime = new Date(args.data.StartTime.setHours(9, 0, 0));
args.data.EndTime = new Date(args.data.EndTime.setHours(9, 30, 0));
}
var startElement = args.element.querySelector('#StartTime');
if (!startElement.classList.contains('e-datetimepicker')) {
new ej.calendars.DateTimePicker({ value: args.data.StartTime || new Date() }, startElement);
}
var endElement = args.element.querySelector('#EndTime');
if (!endElement.classList.contains('e-datetimepicker')) {
new ej.calendars.DateTimePicker({ value: args.data.EndTime || new Date() }, endElement);
}
}
Refer to the below shared UG to know about how to drag the popup.
function onPopupOpen(args) {
var dragElement = args.element;
var draggable = new ej.base.Draggable(dragElement, { clone: false });}
答案3
得分: 0
我用这段代码创建了它:
var titleTextElement = args.element.querySelector('.e-title-text');
var startElement = args.element.querySelector('#START_DATE');
var endElement = args.element.querySelector('#END_DATE');
if (titleTextElement.innerText === 'Edit Event') {
new ej.calendars.DateTimePicker({ value: new Date(startElement.value), format: "yyyy-MM-dd HH:mm:ss" }, startElement);
new ej.calendars.DateTimePicker({ value: new Date(endElement.value), format: "yyyy-MM-dd HH:mm:ss" }, endElement);
}
else{
var initialDate = new Date(startElement.value);
initialDate.setHours(9, 0, 0);
new ej.calendars.DateTimePicker({ value: initialDate, format: "yyyy-MM-dd HH:mm:ss" }, startElement);
initialDate = new Date(endElement.value);
initialDate.setHours(9, 30, 0);
new ej.calendars.DateTimePicker({ value: initialDate, format: "yyyy-MM-dd HH:mm:ss" }, endElement);
}
英文:
I made it with this code
var titleTextElement = args.element.querySelector('.e-title-text');
var startElement = args.element.querySelector('#START_DATE');
var endElement = args.element.querySelector('#END_DATE');
if (titleTextElement.innerText === 'Edit Event') {
new ej.calendars.DateTimePicker({ value: new Date(startElement.value), format: "yyyy-MM-dd HH:mm:ss" }, startElement);
new ej.calendars.DateTimePicker({ value: new Date(endElement.value), format: "yyyy-MM-dd HH:mm:ss" }, endElement);
}
else{
var initialDate = new Date(startElement.value);
initialDate.setHours(9, 0, 0);
new ej.calendars.DateTimePicker({ value: initialDate, format: "yyyy-MM-dd HH:mm:ss" }, startElement);
initialDate = new Date(endElement.value);
initialDate.setHours(9, 30, 0);
new ej.calendars.DateTimePicker({ value: initialDate, format: "yyyy-MM-dd HH:mm:ss" }, endElement);
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论