-
-
Notifications
You must be signed in to change notification settings - Fork 14
Home
Emrah KONDUR edited this page Mar 4, 2020
·
7 revisions
EFDatatable is a helper to create a grid with Jquery Datatable and provides an extension to retrive data generically from Entity Framework context. It possible to use many datatable.js features with Html helper. It gives serverside or client side options.
@(Html.EF().Datatable<Person>()
.Name("PersonGrid")
.Columns(cols =>
{
cols.Field(a => a.Id).Visible(false);
cols.Field(a => a.Name).Title("First Name").Class("text-danger");
cols.Field(a => a.Age).Title("Age").Searchable(false);
cols.Field(a => a.BirthDate).Title("Birth Date").Format("DD-MMM-Y");
cols.Command(a => a.Id, "onClick", text: "Click").Title("");
})
.Filters(filter =>
{
filter.Add(a => a.Id).GreaterThanOrEqual(1);
})
.URL(Url.Action("GetDataResult"), "POST")
.ServerSide(true)
.Render()
)
With .ToDataResult(request)
extension function, data can get with server side pagination very simply.
public JsonResult GetDataResult(DataRequest request)
{
DataResult result = context.People.ToDataResult(request);
return Json(result);
}