Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
145243 | Jun 13,2019 12:12 PM UTC | Jun 19,2019 09:21 AM UTC | Angular - EJ 2 | 3 |
![]() |
Tags: Grid |
App.component.html
<button ejs-button id='print' (click)='buttonClick()'>Change Locale</button>
<ejs-grid #grid [dataSource]='data' allowPaging='true' (dataBound)="databound($event)" [allowPdfExport]='true' >
<e-columns>
<e-column field='OrderID' headerText='Order ID' width='120' textAlign='Right'></e-column>
<e-column field='Freight' headerText='Freight' type='number' width='120' format='C2'></e-column>
<e-column field='OrderDate' headerText='Order Date' type='date' width='130' format="yMd" textAlign='Right'></e-column>
<e-column field='ShipCountry' headerText='Ship Country' width='170'></e-column>
</e-columns>
</ejs-grid>
App.component.ts
export class DefaultComponent implements OnInit {
public data: Object[] = [];
@ViewChild('grid')
public grid: GridComponent;
public initialPage: Object;
public toolbar;
public cultureChange = false;
ngOnInit(): void {
this.data = orderDatas;
}
buttonClick(args) {
this.cultureChange = true;
setCulture('pt'); // Change the Grid culture
setCurrencyCode("BRL"); // Change the currency code
}
databound(args) {
if(this.cultureChange){
this.cultureChange = false;
}
}
} |
App.component.html
<button ejs-button id='print' (click)='buttonClick()'>Change Locale</button>
<ejs-grid #grid [dataSource]='data' allowPaging='true' [allowPdfExport]='true' >
<e-columns>
<e-column field='OrderID' headerText='Order ID' width='120' textAlign='Right'></e-column>
<e-column field='Freight' headerText='Freight' type='number' width='120' format='C2'></e-column>
<e-column field='OrderDate' headerText='Order Date' type='date' width='130' format='yMd' textAlign='Right'></e-column>
<e-column field='ShipCountry' headerText='Ship Country' width='170'></e-column>
</e-columns>
</ejs-grid>
App.component.ts
import { Component, OnInit, ViewChild } from '@angular/core';
import { L10n, loadCldr, setCulture, setCurrencyCode } from '@syncfusion/ej2-base';
import { orderDatas } from './data';
import { GridComponent } from '@syncfusion/ej2-angular-grids';
import * as cagregorian from "./ca-gregorian.json";
import * as currencies from "./currencies.json";
import * as numbers from "./numbers.json";
import * as timeZoneNames from "./timeZoneNames.json";
loadCldr(cagregorian, currencies, numbers, timeZoneNames); // load json files
@Component({
selector: 'control-content',
templateUrl: 'default.html'
})
export class DefaultComponent implements OnInit {
public data: Object[] = [];
@ViewChild('grid')
public grid: GridComponent;
public initialPage: Object;
public toolbar;
public cultureChange = false;
ngOnInit(): void {
this.data = orderDatas;
}
buttonClick(args) {
this.cultureChange = true;
setCulture('de'); // Change the Grid culture
setCurrencyCode('EUR');// Change the currency code
}
} |
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.