Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
142823 | Feb 21,2019 03:57 AM UTC | Nov 6,2020 01:14 PM UTC | ASP.NET MVC - EJ 2 | 5 |
![]() |
Tags: Grid |
@Html.EJS().Grid("FlatGrid").DataSource((IEnumerable<object>)ViewBag.dataSource).QueryCellInfo("querycellinfo").Columns(col =>
{
col.HeaderText("Row Numer").Width("90").Add();
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").Width("110").Add();
col.Field("Freight").HeaderText("Freight").EditType("numericedit").Width("120").Add();
col.Field("ShipCountry").HeaderText("Ship Country").Width("150").Add();
}).AllowPaging().Render()
<script>
var count = 1;
function querycellinfo(args) {
if (args.column.headerText == "Row Numer") {
args.cell.innerHTML = count;
count++;
}
}
</script>
|
if (args.requestType == "paging" || args.requestType == "sorting" || args.requestType == "grouping" || args.requestType == "filtering" || args.requestType == "searching" || args.requestType == "close") count = 1; |
<div>
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.datasource).AllowPaging().Columns(col =>
{
col.HeaderText("RowNumber").Add();
col.Field("OrderID").HeaderText("Order ID").Add();
col.Field("EmployeeID").HeaderText("Employee ID").IsPrimaryKey(true).Add();
col.Field("ShipCountry").HeaderText("Ship Country").Add();
}).RowDataBound("rowDataBound").PageSettings(page => { page.PageSize(4); }).Render()
</div>
<script>
function rowDataBound(args) {
if (this.pagerModule.pagerObj.currentPage == 1) {
args.row.querySelector('td').innerText = +args.row.getAttribute('aria-rowindex') + 1;
}
else {
var num = (this.pagerModule.pagerObj.currentPage - 1) * this.pagerModule.pageSettings.pageSize;
args.row.querySelector('td').innerText = +args.row.getAttribute('aria-rowindex') + 1 + num;
}
}
</script>
|
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.