@syncfusion/ej2-grids
Version:
Feature-rich JavaScript datagrid (datatable) control with built-in support for editing, filtering, grouping, paging, sorting, and exporting to Excel.
54 lines (53 loc) • 1.82 kB
JavaScript
import { isNullOrUndefined } from '@syncfusion/ej2-base';
import { Internationalization, setCulture } from '@syncfusion/ej2-base';
/**
* ValueFormatter class to globalize the value.
*
* @hidden
*/
var ValueFormatter = /** @class */ (function () {
function ValueFormatter(cultureName) {
this.intl = new Internationalization();
if (!isNullOrUndefined(cultureName)) {
this.intl.culture = cultureName;
}
}
ValueFormatter.prototype.getFormatFunction = function (format) {
if (!isNullOrUndefined(format) && (format.type === 'dateTime' || format.type === 'datetime' || format.type === 'date' || format.type === 'time')) {
return this.intl.getDateFormat(format);
}
else {
return this.intl.getNumberFormat(format);
}
};
ValueFormatter.prototype.getParserFunction = function (format) {
if (format.type) {
return this.intl.getDateParser(format);
}
else {
return this.intl.getNumberParser(format);
}
};
ValueFormatter.prototype.fromView = function (value, format, type) {
if ((type === 'date' || type === 'datetime' || type === 'number') && (!isNullOrUndefined(format))) {
return format(value);
}
else {
return value;
}
};
ValueFormatter.prototype.toView = function (value, format) {
var result = value;
if (!isNullOrUndefined(format) && !isNullOrUndefined(value)) {
result = format(value);
}
return result;
};
ValueFormatter.prototype.setCulture = function (cultureName) {
if (!isNullOrUndefined(cultureName)) {
setCulture(cultureName);
}
};
return ValueFormatter;
}());
export { ValueFormatter };