<body>
..
<script type="text/javascript">
$(function () {
$("#Grid").ejGrid({
dataSource: ej.parseJSON([{ "EmployeeID": 1, "StartDate": "2016-01-01T00:00:00-03:00" }, { "EmployeeID": 2, "StartDate": "2016-01-01T00:00:00-03:00" }, { "EmployeeID": 3, "StartDate": "2016-01-01T00:00:00-03:00" }, { "EmployeeID": 4, "StartDate": "2016-01-01T00:00:00-03:00" }]),
… columns: [
…
],
});
});
</script>
|
[GridFeatures.cshtml]
<div id="FlatGrid"></div>
<script type="text/javascript">
$(function () {
var productId = @Html.Raw(Json.Encode(ViewBag.datasource));
$("#FlatGrid").ejGrid({
dataSource: ej.parseJSON(productId),
columns: [
...
{ field: "OrderDate", headerText: "Order Date", format: "{0:dd/MM/yyyy}", width: 130 }
]
});
});
</script>
[GridController.cs]
private void BindDataSource()
{
int code = 10000;
for (int i = 1; i < 10; i++)
{
order.Add(new Orders(code + 1, "TOMSP", i + 0, 2.3 * i, "Münster", "Toms Spezialitäten", "2016-01-01T00:00:00-03:00", "Germany", "44087", false));
...
code += 5;
}
} |
<script type="text/javascript">
var serverTimeZoneDiff = -4.0 // if your server is in EDT time zone (UTC -4.0) (in hours)
var clientSideTimeZoneDiff = new Date().getTimezoneOffset() / 60; // get client time zone difference and convert it to hours;
ej.serverTimezoneOffset = serverTimeZoneDiff + clientSideTimeZoneDiff;
$(function () {
$("#Grid").ejGrid({
dataSource: dm,
allowPaging: true,
load:onLoad,
columns: ["OrderID", "EmployeeID", "CustomerID", "OrderDate", "Freight"]
});
});
function onLoad(args) {
//on parsing the dataSource
//Dates will be coverted to original timeZone
this.model.dataSource = ej.parseJSON(this.model.dataSource);
}
</script> |
Index.cshtml
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
<script src="~/lib/jsrender/jsrender.js"></script>
<script src="~/lib/jquery.validation/dist/jquery.validate.js"></script>
<script type="text/javascript" src="https://cdn.syncfusion.com/16.1.0.24/js/web/ej.web.all.js"></script>
<script src="~/lib/ej.culture.pl-PL.js"></script>
<script src="~/lib/ej.culture.pl-PL.min.js"></script>
<div class="row">
<div class="col-md-12">
<ej-grid id="FlatGrid" allow-paging="true" locale="pl-PL" allow-grouping="true">
<e-datamanager url="/Home/DataSource" batch-url="/Home/BatchUpdate" adaptor="UrlAdaptor" />
. . .
</e-columns>
</ej-grid>
|
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc().AddXmlSerializerFormatters()
.AddJsonOptions(x =>
{
x.SerializerSettings.DateParseHandling = Newtonsoft.Json.DateParseHandling.None;
x.SerializerSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Local;
x.SerializerSettings.ContractResolver = null; });
services.AddCors(options => options.AddPolicy("AllowAll", p => p.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()));
}
|