jQWidgets Forums
jQuery UI Widgets › Forums › Angular › jqxDateTimeInput value as date
This topic contains 13 replies, has 2 voices, and was last updated by EP 6 years ago.
-
Author
-
with Angular 2-way binding jqxDateTimeInput changes a Date-typed Component-property to string, related to formatString.
As I must pass Date to HTTP-Request it would be hard to manage all culture spec. formatStrings.
Is there any way to get a value from jqxDateTime as Date (-typed) independent from formatString / culture settingHello EP,
Please review the following example whether it fits your needs.
Let us know if you need further assistance.
Best Regards,
TodorjQWidgets Team
https://www.jqwidgets.comPerfect,
thanks a lot Todor, exactly what I was searchig for.
I was using the jqxDateTimeInputComponent in a wrong manner.
The Problem was / is:
I need (angular component) to access@ViewChild('dateTo') dateTo: jqxDateTimeInputComponent; dataAdapter: any = new jqx.dataAdapter(this.source, { formatData: (data) => { ...
from within an override of dataAdapter.formatData to pass the date to the http-request
but from within formatData [this] is the datadapter and I don’t know how to reachdateTo
Could not find any hint in documentationAny idea?
sorry not correct, I got
dataAdapter: any = new jqx.dataAdapter(this.source,
{
formatData: (data) => {
console.log(this); // => the Angular component
console.log(this.dateFrom); // => jqxDateTimeInputComponent�
console.log(this.dateFrom.getDate); // => ƒ () { return this.host.jqxDateTimeInput(‘getDate’); }
console.log(this.dateFrom.getDate()); // => nullvery strange, isn’t it?
Hello EP,
Try to change this.dateFrom to this.dateTo as your jqxDateTimeInputComponent reference is dateTo.
If this doesn’t work could you please share a stackblitz/codesandbox example with your code and we would be able to properly investigate it?Best Regards,
TodorjQWidgets Team
https://www.jqwidgets.comHello Todor,
there are two of them dateFrom and dateTo
I put an example on https://llqixxan.github.stackblitz.io/formatData (data) =>
formatData error: TypeError: “_this.dateFrom.getDate(…) is null”sorry, https://llqixxan.github.stackblitz.io/ is not correct
this is the right one:
https://github-l6zbx3.stackblitz.io
I hope
(Data d not arrive due to COS SOP. ut this is not the problemHello EP,
Unfortunately I cannot open the given link. Could you please use stackblitz.com not .io? You could use my example from above from stackblitz.com as template and write your code there.
Best Regards,
TodorjQWidgets Team
https://www.jqwidgets.comHello Todor,
stackblitz is:
https://stackblitz.com/edit/github-l6zbx3
https://github-l6zbx3.stackblitz.io/as I said no data is arriving but errormessage you’ll see in log (Refresh works well, but dataAdapter.formatData: (data) does not.
Assume it is a “this” problem (Typescript or fat arrow function)
Edgar
I did also look at your demo
https://www.jqwidgets.com/angular/angular-datetimeinput/#https://www.jqwidgets.com/angular/angular-datetimeinput/angular-datetimeinput-localization.htm
and I found it, not to work correctly
if I choose another date like May, 23
select english
date is shown as 23/05/2019
but should be 05/23/2019
same thing happens at https://parixklg.github.stackblitz.io
even more herein, if I set [showTimeButton]=”true” timeinput does not popup properlyplease postpone my last message
it was raised by the mis assumption the culture-selection was coupled to the date format-selection which basically seems not to be the case at least not without further steps.
I’m driven by the intent to setup locale / culture specific issues globally for the SPA by a single setting. I hope, I’m not to far away from a solution, but have to work it out.PS: if formatstring is set properly, the timeselector-control of the jqxDateTimeInput also works properly.
But away from that, the component-property access in the callbacks is still my primary issue.
Hello EP,
I’ve updated your example. I’ve replaced [(ngModel)] with [value] which is a property of jqxDateTimeInput.
Let us know if you need further assistance.
Best Regards,
TodorjQWidgets Team
https://www.jqwidgets.comHello Todor,
works indeed thanks a lot! -
AuthorPosts
You must be logged in to reply to this topic.