Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
147740 | Sep 20,2019 09:24 AM UTC | Mar 26,2020 03:29 AM UTC | Angular - EJ 2 | 7 |
![]() |
Tags: Grid |
In grid.component.html
<ejs-grid id="Grid" [dataSource]="gridData" allowPaging="true" >
<e-columns>
<e-column field="OrderID" [isPrimaryKey]="true" headerText="{{ 'Value' | translate }}"></e-column>
<e-column field="Freight" headerText="Freight" ></e-column>
</e-columns>
</ejs-grid>
In grid.component.ts
import { Component } from '@angular/core';
import {TranslateService} from '@ngx-translate/core';
@Component({
selector: 'app-root',
templateUrl: '. /grid.component.html',
})
export class GridComponent {
constructor(translate: TranslateService) {
translate.addLangs(['en', 'fr']) // tells the service which languages are available for translation
translate.setDefaultLang('en'); // allows to specify set of translation to use in case there are missing translation for current language
translate.use('fr');// tells the service which is current language
}
}
In assets/i18n/en.json
{
"Value": "Order ID!"
}
In assets/i18n/fr.json
{
"Value": "numéro de commande!"
}
|
<div>
<ejs-grid #grid [toolbar]='toolbar' [dataSource]="dataSource">
<e-columns>
. . .
</e-columns>
</ejs-grid>
</div>
<ng-template #toolbar1>
<button class="btn btn-secondary btn-toolbar">{{ 'All' | translate }}</button>
</ng-template>
|
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent implements OnInit {
@ViewChild("toolbar1")
public toolbar1: any;
constructor(private translate: TranslateService) {
translate.addLangs(['en', 'fr']) // tells the service which languages are available for translation
translate.use('fr');// tells the service which is current language
}
ngOnInit() {
this.toolbar = [
{ template: this.toolbar1, id: 'selectall' },
. . .
];
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.