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,
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
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?
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.
Code snippet:
//dataPickerProvider.clear(); dataPickerProvider.setDate(new Date());
Thank you for your solution.
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?
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.
Hi @Benjith Sam ,I have the following problem after asking for your advice:+ If I refresh the screen, it works normally.
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?
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.
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.
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
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.
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.
Thank you for your solution.However, it doesn't solve my problem.
Hello
There is no such direct way as I know, So by applying a Js function we can achieve this
Implementation Steps:
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
I am also attaching Sample Oml that can help
Sample
You are welcome,
I am glad I was able to help :)
Thanks
Hi @Tousif KhanI 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?
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