@Html.EJS().Grid("FlatGrid").DataSource((IEnumerable<object>)ViewBag.dataSource).ShowColumnChooser(true).Columns(col =>
{ col.Field("EmployeeID").HeaderText("Employee ID").IsPrimaryKey(true).Width("120").Add();
col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add();
col.Field("OrderDate").HeaderText("Order Date").Type("date").Format(format).Width("110").Add();
col.Field("Freight").HeaderText("Freight").Width("120").ValueAccessor("valueAccess").Add();
col.Field("ShipCountry").Visible(false).HeaderText("Ship Country").Width("150").Add();
}).AllowPaging().Render()
<script>
function valueAccess(field, data, column) {
var format = "R$ ";
var value = data.Freight.toString();
return format + value.replace('.', ',');
}
</script>
|
[Index.cshtml]
<script>
ej.base.L10n.load({ // for text translations
'pt': {
'grid': {
EmptyRecord: 'Nenhum registro para exibir',
True: 'real',
...
},
'pager': {
currentPageInfo: '{0} de {1} páginas',
totalItemsInfo: '(Elementos {0})',
...
}
}
});
</script>
<div>
@Html.EJS().Grid("Grid").Locale("pt").DataSource((IEnumerable<object>)ViewBag.datasource).Columns(col =>
{
...
}).AllowPaging().EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Normal); }).Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).Render()
</div> |
[_Layout.cshtml]
...
<script>
function loadCultureFiles(name) { //for number format translations
var files = ['numbers.json', 'timeZoneNames.json', 'currencies.json', 'ca-gregorian.json'];
var loadCulture = function (prop) {
var val, ajax;
ajax = new ej.base.Ajax(location.origin + '/../../scripts/cldr-data/main/' + name + '/' + files[prop], 'GET', true);
ajax.onSuccess = function (value) {
val = value;
ej.base.loadCldr(JSON.parse(val));
};
ajax.send();
ej.base.setCulture('pt');
};
for (var prop = 0; prop < files.length; prop++) {
loadCulture(prop);
}
}
document.addEventListener('DOMContentLoaded', function () {
loadCultureFiles('pt');
});
</script>
...
|