197
Views
20
Comments
Solved
[Reactive Web] Mark dark color for the weekend and unclickable on DatePicker
Question
Application Type
Reactive
Service Studio Version
11.53.22 (Build 61488)

Hi I have the DatePicker as shown below 

I'm trying to disable Sunday and Saturday, however I can't find any solution.

I have consulted the solutions in the forum but none of them worked for my case.

So if anyone has a suitable solution, let me know


Many thanks,

2021-03-18 21-03-15
Benjith Sam
 
MVP
Solution

Hi Lam,

In addition to the previous comments. Refer to this solution post: Disable_Datepicker_Days

I hope this helps you!


Kind regards,

Benjith Sam

2022-11-01 01-58-16
Lam Thai Dinh

Hi @Benjith Sam ,
I have a problem after I apply the solution you recommend as below:
I have configured InitialDate = CurrDate().
But the initialDate value is reset.I think it's because of this code: dataPickerProvider.clear();
Could you give how to solve this problem?

2021-03-18 21-03-15
Benjith Sam
 
MVP
Solution

Hi Lam,

I would suggest not setting the DatePicker InitialDate property value. Instead, apply the below-mentioned changes to the JS code to set the Initial date value to the Date picker.

  • Comment the date clear statement
  • call the setDate() function to set the date to the DatePicker

Code snippet:

//dataPickerProvider.clear();
dataPickerProvider.setDate(new Date());

I hope this helps you!


Kind regards,

Benjith Sam

2022-11-01 01-58-16
Lam Thai Dinh
2022-11-01 01-58-16
Lam Thai Dinh

Hi @Benjith Sam ,
Beside, when I click the today link, nothing happens. My expectation is set today's date for calendar.Could you give how to solve this problems?

2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Lam,

Sorry for my late reply. I observed that the DatePicker Today button is working as expected in my case. I hope you already fixed the issue, If not, check the console for errors or share a sample oml with the implementation. 


Kind regards,

Benjith Sam

2022-11-01 01-58-16
Lam Thai Dinh

Hi @Benjith Sam ,
I have the following problem after asking for your advice:
+ If I refresh the screen, it works normally.

but when I clicked on the link, it did not work and an error occurred.





Please let me know if you have any suggestions for how to resolve this issue.

Many thanks,

2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Lam,

I'm not fully able to understand which link you are referring to. If possible can you share a sample oml or a screen capture to better understand the flow and implementation?


Kind regards,

Benjith Sam

2022-11-01 01-58-16
Lam Thai Dinh

Hi @Benjith Sam ,

I was using Interaction\DatePicker and confirming as below:

And I created a javascript as below in the DatePickerInitialized action:

function weekends(date) {    


     return (date.getDay() === 0 || date.getDay() === 6);


}

var dataPickerProvider = OutSystems.OSUI.Patterns.DatePickerAPI.GetDatePickerItemById($parameters.DatePickerWidgetId)._provider;

dataPickerProvider.config._disable = [weekends];

dataPickerProvider.setDate(new Date());

Let me know if you want any information.
Many thank.

2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Lam,

Unfortunately, I'm not able to reproduce the mentioned observation with the stated configuration. If possible can you share a sample oml with your implementation? And also explain what you mean by - 'but when I clicked on the link, it did not work and an error occurred'. BTW, it is a console warning message not an error.


Kind regards,

Benjith Sam

2022-11-01 01-58-16
Lam Thai Dinh

Hi @Benjith Sam ,

I sent to you DatePickerTest screen as below. 

If you want to reproduce, please click the DatePickerTest link on the top menu.

Link refer: https://lamthai.outsystemscloud.com/MyApp/DatePickerTest

Thanks,

Lam

MyApp.oml
2022-11-01 01-58-16
Lam Thai Dinh

Hi @Benjith Sam,

I found the root cause of the issue. The reason is the "onReady" action of DatePicker.

OutSystems.OSUI.Patterns.DatePickerAPI.Initialize($parameters.UniqueId);

This resets the setting InstanceInitializedHandler.

So I think OutSystems should reconsider this OnReady action.

My solution currently is to set a timeout for my function so that function always runs after an OnReady action.

2021-03-18 21-03-15
Benjith Sam
 
MVP
Solution

Hi Lam,

I would suggest not setting the DatePicker InitialDate property value. Instead, apply the below-mentioned changes to the JS code to set the Initial date value to the Date picker.

  • Comment the date clear statement
  • call the setDate() function to set the date to the DatePicker

Code snippet:

//dataPickerProvider.clear();
dataPickerProvider.setDate(new Date());

I hope this helps you!


Kind regards,

Benjith Sam

2023-08-28 09-08-29
Venkatesh Sundarajan

Hi Lam Thai, 

Please try the approach mentioned in the below link, 

https://www.outsystems.com/forums/discussion/82102/disable-saturday-and-sunday-in-datepicker/

On your Input widget, 

Attributes section please set "disableWeekends=true".

This should help you. 

Thanks. 

2022-11-01 01-58-16
Lam Thai Dinh

Thank you for your solution.
However, it doesn't solve my problem. 

2023-10-21 19-42-11
Tousif Khan
Champion

Hello

There is no such direct way as I know, So by applying a Js function we can achieve this

Implementation Steps:

  • Define the DatePicker OnInitialize handler 
  • Add a Js Node to your flow 
  • Pass the DatePicker Widget ID
  • Define Weedkend function to disable

And To modify the colors we can define css in a style

JS Snipet

function weekends(date) {    return (date.getDay() === 0 || date.getDay() === 6);}var dataPickerProvider = OutSystems.OSUI.Patterns.DatePickerAPI.GetDatePickerItemById($parameters.DatePickerWidgetId)._provider;dataPickerProvider.config._disable = [weekends];dataPickerProvider.clear();

CSS

.flatpickr-day.flatpickr-disabled, .flatpickr-day.flatpickr-disabled:hover {    cursor: not-allowed;   background: aliceblue; color: black !important; text-decoration: line-through; }


Note : You can further customize Css according to you


am also attaching Sample Oml that can help

Sample

DemoApplication_DatePicker_Disable_Weekend.oml
2022-11-01 01-58-16
Lam Thai Dinh

Thank you for your solution.

2023-10-21 19-42-11
Tousif Khan
Champion

You are welcome,

I am glad I was able to help :)

Thanks

2022-11-01 01-58-16
Lam Thai Dinh

Hi @Tousif Khan
I have a problem after I apply the solution you recommend as below:
I have configured InitialDate = CurrDate().
But the initialDate value is reset.I think it's because of this code: dataPickerProvider.clear();
Beside, when I click the today link, nothing happens. My expectation is set today's date for calendar.Could you give how to solve this problems?

2022-03-14 16-37-00
Hidayat Ali M Mujawar

Hi @Lam Thai Dinh 

I hope you are doing good.

Please find the below solution for saturday and sunday disabled. in properties tab of datpicker Under advancedFormat provide json value "{disableWeekends:true}" for AdvancedFormatJSON attribute

Also find the demo link for the same : 

https://personal-aovk3pan.outsystemscloud.com/DatePickerTest/DatePickerTest.aspx?_ts=638024654624363104


2022-11-01 01-58-16
Lam Thai Dinh

Thank you for your solution.
However, it doesn't solve my problem.

2021-03-18 21-03-15
Benjith Sam
 
MVP
Solution

Hi Lam,

In addition to the previous comments. Refer to this solution post: Disable_Datepicker_Days

I hope this helps you!


Kind regards,

Benjith Sam

2022-11-01 01-58-16
Lam Thai Dinh

Hi @Benjith Sam ,
I have a problem after I apply the solution you recommend as below:
I have configured InitialDate = CurrDate().
But the initialDate value is reset.I think it's because of this code: dataPickerProvider.clear();
Could you give how to solve this problem?

2021-03-18 21-03-15
Benjith Sam
 
MVP
Solution

Hi Lam,

I would suggest not setting the DatePicker InitialDate property value. Instead, apply the below-mentioned changes to the JS code to set the Initial date value to the Date picker.

  • Comment the date clear statement
  • call the setDate() function to set the date to the DatePicker

Code snippet:

//dataPickerProvider.clear();
dataPickerProvider.setDate(new Date());

I hope this helps you!


Kind regards,

Benjith Sam

2022-11-01 01-58-16
Lam Thai Dinh
2022-11-01 01-58-16
Lam Thai Dinh

Hi @Benjith Sam ,
Beside, when I click the today link, nothing happens. My expectation is set today's date for calendar.Could you give how to solve this problems?

2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Lam,

Sorry for my late reply. I observed that the DatePicker Today button is working as expected in my case. I hope you already fixed the issue, If not, check the console for errors or share a sample oml with the implementation. 


Kind regards,

Benjith Sam

2022-11-01 01-58-16
Lam Thai Dinh

Hi @Benjith Sam ,
I have the following problem after asking for your advice:
+ If I refresh the screen, it works normally.

but when I clicked on the link, it did not work and an error occurred.





Please let me know if you have any suggestions for how to resolve this issue.

Many thanks,

2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Lam,

I'm not fully able to understand which link you are referring to. If possible can you share a sample oml or a screen capture to better understand the flow and implementation?


Kind regards,

Benjith Sam

2022-11-01 01-58-16
Lam Thai Dinh

Hi @Benjith Sam ,

I was using Interaction\DatePicker and confirming as below:

And I created a javascript as below in the DatePickerInitialized action:

function weekends(date) {    


     return (date.getDay() === 0 || date.getDay() === 6);


}

var dataPickerProvider = OutSystems.OSUI.Patterns.DatePickerAPI.GetDatePickerItemById($parameters.DatePickerWidgetId)._provider;

dataPickerProvider.config._disable = [weekends];

dataPickerProvider.setDate(new Date());

Let me know if you want any information.
Many thank.

2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Lam,

Unfortunately, I'm not able to reproduce the mentioned observation with the stated configuration. If possible can you share a sample oml with your implementation? And also explain what you mean by - 'but when I clicked on the link, it did not work and an error occurred'. BTW, it is a console warning message not an error.


Kind regards,

Benjith Sam

2022-11-01 01-58-16
Lam Thai Dinh

Hi @Benjith Sam ,

I sent to you DatePickerTest screen as below. 

If you want to reproduce, please click the DatePickerTest link on the top menu.

Link refer: https://lamthai.outsystemscloud.com/MyApp/DatePickerTest

Thanks,

Lam

MyApp.oml
2022-11-01 01-58-16
Lam Thai Dinh

Hi @Benjith Sam,

I found the root cause of the issue. The reason is the "onReady" action of DatePicker.

OutSystems.OSUI.Patterns.DatePickerAPI.Initialize($parameters.UniqueId);

This resets the setting InstanceInitializedHandler.

So I think OutSystems should reconsider this OnReady action.

My solution currently is to set a timeout for my function so that function always runs after an OnReady action.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.