Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
144253 | Apr 26,2019 07:18 PM UTC | Jun 10,2019 06:20 PM UTC | ASP.NET Core - EJ 2 | 4 |
![]() |
Tags: DataGrid |
Grid:
@Html.AntiForgeryToken()
<ejs-grid id="Grid" allowPaging="true" load="onLoad" >
<e-grid-editsettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Batch"></e-grid-editsettings>
<e-data-manager url="/Index?handler=DataSource" batchUrl="/Index?handler=BatchUpdate" adaptor="UrlAdaptor"></e-data-manager>
<e-grid-columns>
<e-grid-column field="ShipCity" headerText="Ship City" textAlign="Right" width="120"></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script>
function onLoad() {
this.dataSource.dataSource.headers = [{ 'XSRF-TOKEN': $("input:hidden[name='__RequestVerificationToken']").val() }];
}
</script>
Controller:
namespace Razorpages.Pages
{
public class IndexModel : PageModel
{
public static List<Orders> order = new List<Orders>();
public void OnGet()
{
if (order.Count == 0)
BindDataSource();
}
public class Data
{
public bool requiresCounts { get; set; }
public int skip { get; set; }
public int EmployeeID { get; set; }
public int EmployeeName { get; set; }
public int take { get; set; }
}
public JsonResult OnPostDataSource([FromBody]Data dm)
{
var data = order;
int count = data.Cast<Orders>().Count();
return dm.requiresCounts ? new JsonResult(new { result = data.Skip(dm.skip).Take(dm.take), count = count }) : new JsonResult(data);
}
}
} |
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.