Declined
Last Updated: 19 Dec 2023 12:49 by Ekaterina
Ekaterina
Created on: 11 Dec 2023 09:59
Category: DatePicker
Type: Feature Request
0
Custom Date mask

Hi team.

We would like to provide a possibility to use our specific masks for Date Picker component, like this:

  • d.m.y = Current date
  • 1.m.y = 1st day of current month
  • 31.m.y = Last day of current month
  • etc.

Can you recommend a good solution for this?

 

4 comments
Ekaterina
Posted on: 19 Dec 2023 12:49

Hi, Martin.

We are not going to combine MaskedTextBox and DatePicker, we are planing to use selector what will help customer use one of this components.

Thank you for your help, we will try to implement this solution.

 

Ekaterina.

ADMIN
Martin
Posted on: 19 Dec 2023 08:28

Hi Ekaterina,

Thank you for providing additional details on this case.

In general, the MaskedTextBox and the DatePicker components are intended to serve different purposes, thus they cannot be combined.

The user can type only numeric values inside the DatePicker component and this is by default.

To achieve the desired outcome the developer should tweak the MaskedTextBox component dynamically and based on the typed value to show the desired date or dynamically toggle the visibility of a DatePicker component and a TextBox. However such implementation would rely on a custom business logic that is left in the hands of the developer.

Regards,
Martin
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Ekaterina
Posted on: 18 Dec 2023 09:27

Hi, Martin.

As I explained to your colleague, this is not a formatting task - it is a mask task, so we need components like the MaskedTextBox component, but for a date picker.

For example, we have a mask:

  • A - for Current date
  • B - for 1st day of current month
  • C - for Last day of current month

And when customer type letters/numbers the result should be:

ADMIN
Martin
Posted on: 18 Dec 2023 09:06

Hi Ekaterina,

The developer can set the format option for the DatePicker to a built-in predefined format

the format table is from the Grid docs, but valid for the DatePicker as well:

https://www.telerik.com/kendo-angular-ui/components/grid/columns/formats/#toc-predefined-date-formats

or custom format by using custom date format strings:

https://www.telerik.com/kendo-angular-ui/components/grid/columns/formats/#toc-custom-date-formats

In this case, the developer can set the format of the DatePicker to a custom function that accepts the custom format and parses it to the desired one in the function:

 <kendo-datepicker [format]="setFormat('d.m.y')" > </kendo-datepicker>
  setFormat(format) {
    console.log(format);
    if (format === 'd.m.y') {
      return 'd';
    } 
  }

For scenarios when the last day should be shown, the value of the DatePicker must be changed along with the custom format.

Regards,
Martin
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources