AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 04.03.2024, 04:32   #1  
Blog bot is offline
Blog bot
Участник
 
25,617 / 848 (80) +++++++
Регистрация: 28.10.2006
crmtipoftheday: Tip #1445: Date picker in Power Pages revisited
Источник: https://crmtipoftheday.com/1445/date...ages-revisited
==============

The product has been renamed at least twice since we talked last time about how to restrict the date picker control in now Power Pages. But most importantly that code, according to some reports, no longer works. Fear not, here’s the revised version that works perfectly well in Power Pages (it did 5 minutes ago, anyway).

In this example we have two date controls. We want to restrict the first one to the future dates only and the second one to give us interval of no more than two weeks.

Add the following script to the page containing the form.

function getDatePicker(name) { // return the datepicker for the given column name return $('#' + name) .siblings('.datetimepicker') .data('DateTimePicker');}function initDates(from, to) { console.log('initDates', from, to); // default FROM is today var fromDate = from || moment().startOf('day'); // default required is in 7 days var toDate = to || fromDate.clone().add(7, 'days'); getDatePicker('enabler_datesubmitted').date(fromDate); getDatePicker('enabler_daterequired').date(toDate);}function dateonchange() { var pickerFrom = getDatePicker('enabler_datesubmitted'); var pickerTo = getDatePicker('enabler_daterequired'); var from = pickerFrom.date(); // no past FROM date pickerFrom.minDate(moment().startOf('day')); // force TO date between the next day and 2 weeks if (from && from.isValid()) { var fromplusone = from.clone().add(1, 'days'); var fromplus14 = from.clone().add(2, 'weeks'); pickerTo .minDate(fromplusone) .maxDate(fromplus14); } else { pickerTo.minDate(null); }}$(document).ready(function () { $("#enabler_datesubmitted").next() .on("dp.change", function (e) { dateonchange(); }) initDates();});
And this CSS to fine-tune the accessibility:

.day.disabled > button { text-decoration: line-through; cursor: not-allowed; color: lightgrey; }
The end result: first control only allows selection from today onwards and the second one is restricted from tomorrow until two weeks from now.



Источник: https://crmtipoftheday.com/1445/date...ages-revisited
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
crminthefield: Dynamics 365 and Power Platform Monthly Update-September 2021 Blog bot Dynamics CRM: Blogs 0 11.09.2021 09:04
crmtipoftheday: Tip #1407: How to secure Power Apps portal from making the news Blog bot Dynamics CRM: Blogs 0 24.08.2021 18:13
crminthefield: Dynamics 365 and Power Platform Monthly Update-August 2021 Blog bot Dynamics CRM: Blogs 0 12.08.2021 06:20
crminthefield: Dynamics 365 and Power Platform Monthly Update-July 2021 Blog bot Dynamics CRM: Blogs 0 14.07.2021 02:22
crmtipoftheday: Tip #1327: Validators on user profile pages in Power Apps portals Blog bot Dynamics CRM: Blogs 0 20.02.2020 14:11

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 19:05.