|
bundles.Add(new Bundle("~/bundles/ej2").Include( "~/Scripts/ej2/ej2.min.js")); |
|
bundles.Add(new ScriptBundle ("~/bundles/ej2").Include( "~/Scripts/ej2/ej2.min.js")); |
|
@Html.EJS().Grid("Grid").DataSource(dataManager => { dataManager.Url("/Home/UrlDatasource").UpdateUrl("/Home/Update") Remove").Adaptor("UrlAdaptor"); }).Columns(col =>
{
. . .
}).AllowPaging().AllowPdfExport().Toolbar(new List<string>() { "PdfExport" }).Render() |
|
public class HomeController : Controller
{
. . .
public ActionResult UrlDatasource(DataManagerRequest dm)
{
IEnumerable DataSource = orddata.ToList();
DataOperations operation = new DataOperations();
. . .
int count = DataSource.Cast<OrdersDetails>().Count();
// data should be returned as result and count for UrlADaptor
return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource);
}
} |
@Html.EJS().Grid("EmployeeWeekTimeSummary").DataSource(dataManager => { dataManager.Url(Url.Action("LoadTimeSummaryPerEmployee/", "MachineTimePerEmployee")).Adaptor("UrlAdaptor"); }).ActionComplete("EmployeeWeekTimeSummaryActioncomplete").SelectedRowIndex(0).Height("300").AllowSelection(true).Width("auto").Columns(col => { col.Field("RowId").HeaderText("").IsPrimaryKey(true).AllowEditing(false).HeaderText("").Visible(false).Width("0").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Left).Add(); col.Field("Name").HeaderText("Nom").AllowEditing(false).Visible(true).Width("100").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Left).Add(); col.Field("SundayHours").HeaderText("Dimanche").AllowEditing(false).Visible(true).Width("100").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Left).Add(); col.Field("MondayHours").HeaderText("Lundi").AllowEditing(false).Visible(true).Width("100").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Left).Add(); col.Field("TuesdayHours").HeaderText("Mardi").AllowEditing(false).Visible(true).Width("100").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Left).Add(); col.Field("WednesdayHours").HeaderText("Mercredi").AllowEditing(false).Visible(true).Width("100").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Left).Add(); col.Field("ThursdayHours").HeaderText("Jeudi").AllowEditing(false).Visible(true).Width("100").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Left).Add(); col.Field("FridayHours").HeaderText("Vendredi").AllowEditing(false).Visible(true).Width("100").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Left).Add(); col.Field("SaturdayHours").HeaderText("Samedi").AllowEditing(false).Visible(true).Width("100").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Left).Add(); col.Field("TotalHours").HeaderText("Total").AllowEditing(false).Visible(true).Width("100").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Left).Add(); }).RowSelected("EmployeeSelected").Render() |
[HttpPost] public ActionResult LoadMachineTimePerEmployee(string employeId, DataManagerRequest dm) { List<MachineTimePerEmployeeEditorPopupViewModel> machineTimePerEmployee = new List<MachineTimePerEmployeeEditorPopupViewModel>(); try { //int id = this.LiardIndustriesContext.Employee.Where(e => e.RowUuid.Equals(employeId)).ToList().First().RowId; machineTimePerEmployee = this.LiardIndustriesContext.MachineTimePerEmployee.ToList().OrderBy(mtpe => mtpe.MachineId).Where(mtpe => mtpe.Employee.RowUuid.Equals(employeId) && mtpe.Employee.IsActif == true).Select(mtpe => new MachineTimePerEmployeeEditorPopupViewModel() { machineTimePerEmployee = mtpe }).ToList(); } catch (Exception e) { } //return Json(JsonConvert.SerializeObject(new ResultListViewModel<MachineTimePerEmployeeEditorPopupViewModel>(machineTimePerEmployee)), JsonRequestBehavior.AllowGet); return Json(new { result = machineTimePerEmployee, count = machineTimePerEmployee.Count() }); } |
Answer of my controller in Network Tab
"{\"result\":[{\"MondayHours\":16.0,\"TuesdayHours\":16.0,\"WednesdayHours\":16.0,\"ThursdayHours\":16.0,\"FridayHours\":16.0,\"SaturdayHours\":0.0,\"SundayHours\":0.0,\"TotalHours\":80.0,\"Name\":\"Bob Gratton\",\"RowId\":\"0B98B8E4-B8CA-43DE-90A5-A6103A352BCA\"},{\"MondayHours\":12.0,\"TuesdayHours\":12.0,\"WednesdayHours\":12.0,\"ThursdayHours\":12.0,\"FridayHours\":12.0,\"SaturdayHours\":0.0,\"SundayHours\":0.0,\"TotalHours\":60.0,\"Name\":\"Marc-André Dubois\",\"RowId\":\"7DBE145A-C59E-4E44-A5B5-5E471001E1F8\"},{\"MondayHours\":16.0,\"TuesdayHours\":16.0,\"WednesdayHours\":16.0,\"ThursdayHours\":16.0,\"FridayHours\":16.0,\"SaturdayHours\":0.0,\"SundayHours\":0.0,\"TotalHours\":80.0,\"Name\":\"Employé Test 1\",\"RowId\":\"B3AE8B85-2274-4A3A-BDDA-C971D6E6D13F\"},{\"MondayHours\":14.0,\"TuesdayHours\":14.0,\"WednesdayHours\":14.0,\"ThursdayHours\":14.0,\"FridayHours\":14.0,\"SaturdayHours\":0.0,\"SundayHours\":0.0,\"TotalHours\":70.0,\"Name\":\"Employé Test 2\",\"RowId\":\"990EE2F8-2A0B-4C70-B9F5-9039094FB390\"}],\"count\":4}"