Skip to content
This repository has been archived by the owner on Mar 2, 2018. It is now read-only.

the datetime picker cannot update when user modifying value #217

Open
wqdjl opened this issue Sep 29, 2017 · 3 comments
Open

the datetime picker cannot update when user modifying value #217

wqdjl opened this issue Sep 29, 2017 · 3 comments

Comments

@wqdjl
Copy link

wqdjl commented Sep 29, 2017

when i input value 2017-09-05 and reopen the datepicker ,the date picker still show the last value ;
eg.
image

I have the solution,
Please update datetime-picker.directive.ts' function ngOnChanges. when user modifying value ,you should be call setInputElDateValue、updateDatepicker
eg.

 if (!this.userModifyingValue) {
          setTimeout(() => {
            let dt = this.getDate(date);
            dt.toString = () => NguiDatetime.formatDate(dt, this.dateFormat, this.dateOnly);
            this.ngModel = dt;
            this.inputEl.value = '' + dt;
          })
  } else {
          this.setInputElDateValue(date);
          this.updateDatepicker();
 }

@jiren @lukaselmer @Krisa @boban984

@allenhwkim
Copy link
Contributor

allenhwkim commented Sep 29, 2017

A good idea, I think. Please test and make a PR.
Please also consider that user may enter invalid date. 2017-0x-xx

@wqdjl
Copy link
Author

wqdjl commented Sep 29, 2017

you can valid the value ,
let date: any = new Date(value);
if (date == "Invalid Date")

@faridabbas-dl
Copy link

  • Go to datetime-picker.directive.js file and find below code (in i have this on line 273 check yours.) component.defaultValue = _this.defaultValue || _this.el['dateValue'];
  • simple change the assigned values to _this.el['dateValue'] || _this.defaultValue ;
    it worked for me perfectly because i was using the default-value.
    also similar change in ts file i.e datetime-picker.directive.ts
  • find component.defaultValue = this.defaultValue || this.el['dateValue'];
  • change sequence component.defaultValue = this.el['dateValue'] || this.defaultValue;

in Above fix we prefer the Element value rather then default value .. i.e if value is change by user then popup 'll display from user provided value Otherwise/else default value.
Thanks @wqdjl for hint......

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants