Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
605
How to set locale for igx-timepicker?
posted

We are using generic timepicker columns in our grid, but we cannot figure out how to set the locale for these to show the time information in German, for example.

Here is our template:

            <ng-template igxCellEditor let-val let-cell="cell">
                <igx-time-picker mode="dropdown" [(ngModel)]="cell.editValue">
                    <ng-template igxTimePickerTemplate let-openDialog="openDialog">
                        <igx-input-group type="box" [displayDensity]="'compact'">
                            <igx-prefix>
                                <igx-icon (click)="openDialog(timeInput)">access_time</igx-icon>
                            </igx-prefix>
                            <input #timeInput
                                   igxInput
                                   [igxFocus]="true"
                                   [igxDateTimeEditor]="timeMask"
                                   [locale]="getLocale()"
                                   [igxTextSelection]="true"
                                   [placeholder]="timePlaceholder"
                                   (keydown)="onDateEditorKeyDown($event, cell, this)"
                                   autocomplete="off"
                                   tabindex="0"
                                   [(ngModel)]="cell.editValue" />
                        </igx-input-group>
                    </ng-template>
                </igx-time-picker>
            </ng-template>

Parents
  • 2680
    Offline posted
    Hello Lance,

     

    Thank you for the provided code-snippet.

     

    I have been looking into your question and created a small sample with an IgxGrid that contains a column of type “date” and has an IgxTimePicker as its editor. You can find it here.

     

    In the sample, the parent component of the grid is localized using the igniteui-angular-i18n package as per our Localization topic. As you can observe the IgxTimePicker’s action button “Cancel” is now localized as “Abbrechen”.

     

    Alternatively, if you rather not localize the parent component, you could simply specify the cancelButtonLabel and okButtonLabel to a required string like this:

     

    <igx-time-picker #picker mode="dropdown" cancelButtonLabel="sampleLabel1" okButtonLabel="sampleLabel2">

     

    Please, test the suggested approaches on your side and let me know if I may be of any further assistance.

     

    Sincerely,
    Bozhidara Pachilova
    Associate Software Developer
Reply Children