Customize the Calendar

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Customize the Calendar

Postby c.groefsema » Fri Sep 13, 2019 4:59 pm

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
User avatar
c.groefsema
 
Posts: 26
Joined: Fri Feb 22, 2019 12:40 pm

Re: Customize the Calendar

Postby paronne » Wed Sep 18, 2019 1:41 pm

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
paronne
 
Posts: 202
Joined: Fri Nov 02, 2012 3:21 pm

Re: Customize the Calendar

Postby c.groefsema » Tue Sep 24, 2019 10:02 am

Hi Paolo,

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

Kind regards,
Cooz
User avatar
c.groefsema
 
Posts: 26
Joined: Fri Feb 22, 2019 12:40 pm

Re: Customize the Calendar

Postby Bernd.N » Mon Dec 16, 2019 6:40 pm

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
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 12 guests