Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
142742 | Feb 12,2019 11:03 AM UTC | Feb 22,2019 05:16 AM UTC | ASP.NET MVC | 7 |
![]() |
Tags: Grid |
28-12-2018 | Normal | 9 |
28-12-2018 | Summe | 9 |
17-12-2018 | Normal | 4 |
17-12-2018 | Summe | 4 |
Summe all Tage | 246 |
17-12-2018 | Normal | 4 |
17-12-2018 | Summe | 4 |
28-12-2018 | Normal | 9 |
28-12-2018 | Summe | 9 |
Summe all Tage | 246 |
@(Html.EJS().Grid<EJ2Grid.Controllers.HomeController.Orders>("Grid").DataSource((IEnumerable<object>)ViewBag.data). AllowPaging(true).Columns(col =>
{
col.Field("OrderDate").HeaderText("Order Date").SortComparer("sortComparer").Format("yMd").Width("120").Add();
}).AllowSorting(true).ActionBegin("actionBegin").AllowExcelExport(true).Toolbar(new List<string>() { "ExcelExport" }).Render())
<script type="text/javascript">
var action;
function actionBegin(args) {
if (args.requestType == "sorting") {
action = args.direction;
}
}
function sortComparer(reference, comparer) {
var sortAsc = action === "Ascending" ? true : false;
if (sortAsc && reference === null) {
return 1;
}
else if (sortAsc && comparer === null) {
return -1;
}
else if (!sortAsc && reference === null) {
return -1;
}
else if (!sortAsc && comparer === null) {
return 1;
} else {
return reference - comparer;
}
}
</script> |
<script type="text/javascript">
ej.pvt.fnAscending = function (x, y) {
if (ej.isNullOrUndefined(y) && ej.isNullOrUndefined(x))
return -1;
if (y === null || y === undefined)
return -1;
if (typeof x === "string")
return x.localeCompare(y);
if (x === null || x === undefined)
return 1;
return x - y;
}
ej.pvt.fnDescending = function (x, y) {
if (ej.isNullOrUndefined(y) && ej.isNullOrUndefined(x))
return -1;
if (y === null || y === undefined)
return -1;
if (typeof x === "string")
return x.localeCompare(y) * -1;
if (x === null || x === undefined)
return 1;
return y - x;
}
</script>
@(Html.EJ().Grid<OrdersView>("ForeignKey")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.AllowPaging()
.AllowSorting()
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(90).Add();
col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add();
col.Field("EmployeeID").HeaderText("Employee Name").Width(90).ValidationRules(v => v.AddRule("Compare", true)).Add();
-------
})
) |
public ActionResult Index()
{
BindDataSource();
GridProperties grid = new GridProperties();
List<Column> colList = new List<Column>();
colList.Add(new Column() { Field = "OrderID", IsPrimaryKey = true, HeaderText = "Order ID", TextAlign = Syncfusion.JavaScript.TextAlign.Right, Width = 75, ValidationRules = new Dictionary<string, object>() { { "required", true } } });
colList.Add(new Column() { Field = "OrderDate", HeaderText = "OrderDate", Format = "{0:MM/dd/yyyy }", Width = 100, ValidationRules = new Dictionary<string, object>() { {"required",true} } });
grid.Columns = colList;
grid.DataSource = order.ToList();
return View(grid);
}
|
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.