Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DatePicker with enabled dateInput and set format does not set value if value is in different format #6607

Closed
aleksandarevangelatov opened this issue Oct 15, 2021 · 0 comments
Assignees
Labels
Bug C: DatePicker FP: Completed Sync status with associated Feedback Item SEV: Low
Milestone

Comments

@aleksandarevangelatov
Copy link
Contributor

Bug report

When using a DatePicker with a set format and enabled dateInput configuration, initializing with a value in a different format than the defined one results in initialization of a component without set value.

    <input id="Date" name="Date" type="text" value="09/01/2021 22:10:10">

    <script>
      $("#Date").kendoDatePicker({
        format:"MMMM yyyy",
        min:new Date(1900,0,1,0,0,0,0),
        max:new Date(2021,8,30,0,0,0,0),
        parseFormats:["MM/dd/yyyy HH:mm:ss"],
        dateInput:true
      });
    </script>

Reproduction of the problem

  1. Run this dojo

Current behavior

The DatePicker displays month year instead of the indicated value

Expected/desired behavior

The DatePicker should set the value to the value defined in the input element.

Workaround

As a possibel workaround you can override the _createDateInput function:

kendo.ui.DatePicker.fn._createDateInput = function(options){
          var elVal = this.element.val();

          if (this._dateInput) {
            this._dateInput.destroy();
            this._dateInput = null;
          }

          if (options.dateInput) {
            this._dateInput = new kendo.ui.DateInput(this.element, {
              culture: options.culture,
              format: options.format,
              min: options.min,
              max: options.max
            });

            if (elVal) {
              this.value(elVal);
            }
          }
        };

Example

Environment

  • Kendo UI version: 2021.3.914
  • Browser: [all]
@kendo-bot kendo-bot added the FP: Unplanned Sync status with associated Feedback Item label Oct 15, 2021
@kendo-bot kendo-bot added FP: Unplanned Sync status with associated Feedback Item and removed FP: Unplanned Sync status with associated Feedback Item labels Jan 20, 2022
@ag-petrov ag-petrov self-assigned this Jan 20, 2022
@kendo-bot kendo-bot added the FP: In Development Sync status with associated Feedback Item label Jan 21, 2022
@MilenaCh MilenaCh added this to the 2022.R1.SP.next milestone Jan 28, 2022
@kendo-bot kendo-bot added FP: Completed Sync status with associated Feedback Item and removed FP: In Development Sync status with associated Feedback Item labels Jan 28, 2022
@Dimitar-Goshev Dimitar-Goshev removed the FP: Unplanned Sync status with associated Feedback Item label Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug C: DatePicker FP: Completed Sync status with associated Feedback Item SEV: Low
Projects
None yet
Development

No branches or pull requests

5 participants