|
let grid: Grid = new Grid({
dataSource: data,
columns: [
{ field: 'OrderDate', headerText: 'Order Date', , format: 'yMEd' }, // output format: Thu, 7/4/1996
. . .
],
height: 315
});
grid.appendTo('#Grid'); |
How can i Format it in Locale Format like 24.12.1985 (de-DE)?
|
import { loadCldr, L10n, setCulture, setCurrencyCode } from '@syncfusion/ej2-base';
loadCldr(currencies, cagregorian, numbers, timeZoneNames, numberingSystems);
setCulture('de');
let grid: Grid = new Grid({
columns: [
{ field: 'OrderID', headerText: 'Order ID', textAlign: 'Right', width: 120 },
{ field: 'OrderDate', headerText: 'OrderDate', format:'yMMdd', width: 150 },
]
});
grid.appendTo('#Grid'); |
|
<ejs-grid id="Grid" dataSource="ViewBag.DataSource" allowPaging="true" allowGrouping="true">
...
</ejs-grid>
<script>
function loadCultureFiles(name) {
var files = ['ca-gregorian.json', 'numbers.json', 'timeZoneNames.json'];
...
var loadCulture = function (prop) {
...
if (name === 'ar' && prop === files.length - 1) {
ajax = new ej.base.Ajax(location.origin + '/../../scripts/cldr-data/supplemental/' + files[prop], 'GET', false);
} else {
...
}
...
loader(JSON.parse(val));
};
...
}
document.addEventListener('DOMContentLoaded', function () {
debugger;
calendarObject = document.getElementById('Grid').ej2_instances[0];
loadCultureFiles('de');
calendarObject.locale = 'de';
});
</script> |
|
<div>
<ejs-grid id="Grid" dataSource="ViewBag.DataSource" load="load" allowPaging="true" allowGrouping="true">
<e-grid-columns>
...
<e-grid-column field="OrderDate" headerText="Order Date" width="170"></e-grid-column>
...
</e-grid-columns>
</ejs-grid>
</div>
<script>
function load(args) {
//Here OrderDate is the 3rd column
this.columns[3].format = { type: 'date', format: 'dd/MM/yyyy' };
}
</script> |
|
<div>
<ejs-grid id="Grid" dataSource="ViewBag.DataSource" load="load" allowPaging="true" >
<e-grid-columns>
...
<e-grid-column field="OrderDate" headerText="Order Date" width="170"></e-grid-column>
...
</e-grid-columns>
</ejs-grid>
</div>
<script>
function load(args) {
this.columns[3].format = { type: 'date', format: 'dd/MM/yyyy' };
}
</script>
|
|
|
|
Index.cshtml
<div>
<ejs-grid id="Grid" actionBegin="actionBegin" dataSource="ViewBag.dataSource" allowPaging="true">
<e-grid-pagesettings pageSize="8"></e-grid-pagesettings>
<e-grid-columns>
. . . . . .
<e-grid-column field="OrderDate" headerText="Order Date" type='date' format='yMd' editType="datepickeredit" width="170"></e-grid-column>
. . . . . .
</e-grid-columns>
</ejs-grid>
</div>
<script>
function actionBegin(args) {
if (args.requestType === "add") {
args.data.OrderDate = new Date(); //set the today’s date to the date column
}
}
</script>
|