/// <summary> /// Gets the list of data for use by the jqgrid plug-in /// </summary> public IActionResult OnGetGridDataGroupedByWorKflowId(string sidx, string sord, int _page, int rows) { // using a groupField in the jqgrid passes that field // along with the field to sort, remove the groupField string groupBy = "WorkflowName asc, "; sidx = sidx.Replace(groupBy, ""); int totalRecords = WorkflowStepsMaster.GetRecordCount(); int startRowIndex = ((_page * rows) - rows); List <WorkflowStepsMaster> objWorkflowStepsMasterCol = WorkflowStepsMaster.SelectSkipAndTake(rows, startRowIndex, sidx + " " + sord); int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows); if (objWorkflowStepsMasterCol is null) { return(new JsonResult("{ total = 0, page = 0, records = 0, rows = null }")); } var jsonData = new { total = totalPages, _page, records = totalRecords, rows = ( from objWorkflowStepsMaster in objWorkflowStepsMasterCol select new { id = objWorkflowStepsMaster.StepId, cell = new string[] { objWorkflowStepsMaster.StepId.ToString(), objWorkflowStepsMaster.WorKflowId.HasValue ? objWorkflowStepsMaster.WorKflowId.Value.ToString() : "", objWorkflowStepsMaster.ApprovalLevel, objWorkflowStepsMaster.Description, objWorkflowStepsMaster.AutoApprove, objWorkflowStepsMaster.WaitTime.HasValue ? objWorkflowStepsMaster.WaitTime.Value.ToString() : "", objWorkflowStepsMaster.CreatedBy, objWorkflowStepsMaster.CreatedOn.ToString("d"), objWorkflowStepsMaster.UpdatedBy, objWorkflowStepsMaster.UpdatedOn.ToString("d"), objWorkflowStepsMaster.WorKflowId is null ? "" : objWorkflowStepsMaster.WorKflowIdNavigation.WorkflowName } }).ToArray()
/// <summary> /// Gets the list of data for use by the jqgrid plug-in /// </summary> public IActionResult OnGetGridData(string sidx, string sord, int _page, int rows, bool isforJqGrid = true) { int totalRecords = WorkflowStepsMaster.GetRecordCount(); int startRowIndex = ((_page * rows) - rows); List <WorkflowStepsMaster> objWorkflowStepsMasterCol = WorkflowStepsMaster.SelectSkipAndTake(rows, startRowIndex, sidx + " " + sord); int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows); if (objWorkflowStepsMasterCol is null) { return(new JsonResult("{ total = 0, page = 0, records = 0, rows = null }")); } var jsonData = new { total = totalPages, _page, records = totalRecords, rows = ( from objWorkflowStepsMaster in objWorkflowStepsMasterCol select new { id = objWorkflowStepsMaster.StepId, cell = new string[] { objWorkflowStepsMaster.StepId.ToString(), objWorkflowStepsMaster.WorKflowId.HasValue ? objWorkflowStepsMaster.WorKflowId.Value.ToString() : "", objWorkflowStepsMaster.ApprovalLevel, objWorkflowStepsMaster.Description, objWorkflowStepsMaster.AutoApprove, objWorkflowStepsMaster.WaitTime.HasValue ? objWorkflowStepsMaster.WaitTime.Value.ToString() : "", objWorkflowStepsMaster.CreatedBy, objWorkflowStepsMaster.CreatedOn.ToString("d"), objWorkflowStepsMaster.UpdatedBy, objWorkflowStepsMaster.UpdatedOn.ToString("d") } }).ToArray() }; return(new JsonResult(jsonData)); }
public void GetData(string sidx, string sord, int?_page) { int rows = Functions.GetGridNumberOfRows(); int numberOfPagesToShow = Functions.GetGridNumberOfPagesToShow(); int currentPage = _page is null ? 1 : Convert.ToInt32(_page); int startRowIndex = ((currentPage * rows) - rows); int totalRecords = WorkflowStepsMaster.GetRecordCount(); int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows); List <WorkflowStepsMaster> objWorkflowStepsMasterCol = WorkflowStepsMaster.SelectSkipAndTake(rows, startRowIndex, sidx + " " + sord); // fields and titles string[,] fieldNames = new string[, ] { { "StepId", "Step Id" }, { "WorKflowId", "Wor Kflow Id" }, { "ApprovalLevel", "Approval Level" }, { "Description", "Description" }, { "AutoApprove", "Auto Approve" }, { "WaitTime", "Wait Time" }, { "CreatedBy", "Created By" }, { "CreatedOn", "Created On" }, { "UpdatedBy", "Updated By" }, { "UpdatedOn", "Updated On" } }; // assign properties WorkflowStepsMasterData = objWorkflowStepsMasterCol; WorkflowStepsMasterFieldNames = fieldNames; TotalPages = totalPages; CurrentPage = currentPage; FieldToSort = String.IsNullOrEmpty(sidx) ? "StepId" : sidx; FieldSortOrder = String.IsNullOrEmpty(sord) ? "asc" : sord; FieldToSortWithOrder = String.IsNullOrEmpty(sidx) ? "StepId" : (sidx + " " + sord).Trim(); NumberOfPagesToShow = numberOfPagesToShow; StartPage = Functions.GetPagerStartPage(currentPage, numberOfPagesToShow, totalPages); EndPage = Functions.GetPagerEndPage(StartPage, currentPage, numberOfPagesToShow, totalPages); }
/// <summary> /// Shows how to get the total number of records /// </summary> private void GetRecordCount() { // get the total number of records in the WorkflowStepsMaster table int totalRecordCount = WorkflowStepsMaster.GetRecordCount(); }