<div id = "ControlRegion"> <ejs-grid id="DataGrid" load="load" dataSource ="ViewBag.dataSource" allowPaging="true" allowSorting="true" allowResizing="false" allowFiltering="true" allowGrouping="false" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel","Search" })"> <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Normal"></e-grid-editSettings> <e-grid-pagesettings pageCount="5"></e-grid-pagesettings> <e-grid-filterSettings type="Menu"></e-grid-filterSettings> <e-grid-selectionsettings type="Multiple"></e-grid-selectionsettings> <e-grid-columns> <e-grid-column field="OrderID" validationRules="@(new { required=true})" headerText="Order ID" minWidth="120" width="200" maxWidth="300" textAlign="Right"></e-grid-column> <e-grid-column field="CustomerID" headerText="Customer Name" validationRules="@(new { required=true})" minWidth="8" width="200"></e-grid-column> <e-grid-column field="OrderDate" headerText=" Order Date" editType="datepickeredit" textAlign="Right" format="yMd" minWidth="8" width="200"></e-grid-column> <e-grid-column field="Freight" headerText="Freight" validationRules="@(new { required=true})" allowResizing="true" editType="numericedit" textAlign="Right" format="C2" width="150" minWidth="8"></e-grid-column> <e-grid-column field="ShipName" headerText="Ship Name" minWidth="8" width="300"></e-grid-column> <e-grid-column field="ShippedDate" headerText="Shipped Date" textAlign="Right" format="yMd" allowResizing="false" width="200"></e-grid-column> <e-grid-column field="ShipCountry" headerText="Ship Country" editType="dropdownedit" minWidth="8" width="200"></e-grid-column> <e-grid-column field="Verified" displayAsCheckBox="true" type="boolean" headerText="Verified" editType="booleanedit" minWidth="8" width="200"></e-grid-column> </e-grid-columns> </ejs-grid> </div> @section Scripts{ <script> function load() { this.columns[3].format = { type: 'date', format: 'dd/MM/yyyy' }; } </script> }
|
<body>
<div class="container body-content">
@RenderBody()
</div>
@RenderSection("scripts", required: false)
<ejs-scripts></ejs-scripts>
</body> |
|
<div id="ControlRegion">
<ejs-grid id="DataGrid"
load="load"
dataSource="ViewBag.datasource"
allowPaging="true"
allowSorting="true"
allowResizing="false"
allowFiltering="true"
allowGrouping="false" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel","Search" })">
<e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Normal"></e-grid-editSettings>
<e-grid-columns>
<e-grid-column field="OrderID" validationRules="@(new { required=true})" headerText="Order ID" minWidth="120" width="200" maxWidth="300" textAlign="Right"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer Name" validationRules="@(new { required=true})" minWidth="8" width="200"></e-grid-column>
<e-grid-column field="OrderDate" headerText=" Order Date" editType="datepickeredit" textAlign="Right" format="yMd" minWidth="8" width="200"></e-grid-column>
<e-grid-column field="Freight" headerText="Freight" validationRules="@(new { required=true})" allowResizing="true" editType="numericedit" textAlign="Right" format="C2" width="150" minWidth="8"></e-grid-column>
. . .
</e-grid-columns>
</ejs-grid>
</div>
@section Scripts{
<script>
function load() {
// date format should be set to a date column. In your code it was set to a number column
this.columns[2].format = { type: 'date', format: 'dd/MM/yyyy' };
}
</script>
}
|