Page 1 of 1

Customize the Calendar

PostPosted: Fri Sep 13, 2019 4:59 pm
by c.groefsema
Hi everyone,

In our Servoy application, a lot of Calendars are used to allow datetime entries. New requirements specify that almost every one of them should not allow entering a datetime that lies in the future.
Obviously, I want to customize the Calendar component for this rather than modify every instance - but I haven't got a clue how to go about it. I'm fairly new to Servoy.
Ideally, I'd add an extra boolean property, 'allowFutureDates' that defaults to false, and if it is false, future dates don't show up in the Calendar at all. But that is probably too much to ask for. :)
Can somebody get me in the right direction for handling this - or even better, give an example -- or still even better, both?

Thanks!
Kind regards,
Cooz

Re: Customize the Calendar

PostPosted: Wed Sep 18, 2019 1:41 pm
by paronne
Hi,

if you are using the Calendar component from the BootstrapComponent package insted of the Default Package is possible to set a max/min date at runtime:

Code: Select all
elements.calendarName.setMinMaxDate(minDate,maxDate)


This has to be done for every single calendar element;
You can iterate over all your elements at the onShow of the form and set a min/max date for all your calendar elements

Code: Select all
   for (var i = 0; i < elements.allnames.length; i++) {
      /** @type {RuntimeWebComponent<bootstrapcomponents-calendar>} */
      var el = elements[elements.allnames[i]];
      if (el.getElementType() == "bootstrapcomponents-calendar") {
         el.setMinMaxDate(minDate,maxDate);
      }
   }


Up to you to handle exceptions where you want to allow future dates.
Note: I am using the new RuntimeWebComponent type in JSDoc from the latest Servoy release 2019.09.RC1

Regards,
Paolo

Re: Customize the Calendar

PostPosted: Tue Sep 24, 2019 10:02 am
by c.groefsema
Hi Paolo,

Sorry for my late reply - but thanks! Your suggestion is quite useful. I can continue now.

Kind regards,
Cooz

Re: Customize the Calendar

PostPosted: Mon Dec 16, 2019 6:40 pm
by Bernd.N
When you have another problem, you could also check the datetime-picker from mindfire.
It comes with source code, which means you can change anything you want.
We made good experience with it, and customisation abilities are really good.

https://www.mindfiresolutions.com/Servoy-Module-MfDatePicker.htm