Add dateFormat to PrimeNGConfig and use as default for date controls
I'm submitting a ...
[X] feature request => Please check if request is not on the roadmap already
Current behavior No global setting of dateFormat in PrimeNGConfig.
Expected behavior Set dateFormat in PrimeNGConfig for the application. p-table filter would use the configured format.
What is the motivation / use case for changing the behavior?
p-table filter would use the configured format and any other date controls that the end user cannot configure.
- Angular version:
Angular 11.0.9
- PrimeNG version:
PrimeNG 11.1.0
"dateFormat" must also be used by p-calendar, loading it from PrimeNGConfig. Actually we have to set it each time we use p-calendar.
For now i'm using this directive:
@Directive({
selector: 'p-calendar'
})
export class CalendarDateformatAutosetDirective implements OnInit {
/** Sync host property */
@Input()
dateFormat: string;
constructor(
@Host() @Self() @Optional() private calendar: Calendar,
private primengConfig: PrimeNGConfig,
) { }
ngOnInit() {
if (!this.dateFormat) {
const defaultValue = this.primengConfig.getTranslation('dateFormat');
this.calendar.dateFormat = defaultValue;
this.calendar.updateInputfield();
}
}
}
Hi,
So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you reopen the issue so we can include it in our roadmap? Please don't forget to add your feedback as a comment after reopening the issue. These will be taken into account by us and will contribute to the development of this feature. Thanks a lot for your understanding!
Best Regards,
There are still no options to set date format for the primeng components globally. Could you add such feature to the roadmap please?