Пример #1
0
        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                   = RoleMaster.GetRecordCount();
            int totalPages                     = (int)Math.Ceiling((float)totalRecords / (float)rows);
            List <RoleMaster> objRoleMasterCol = RoleMaster.SelectSkipAndTake(rows, startRowIndex, sidx + " " + sord);

            // fields and titles
            string[,] fieldNames = new string[, ] {
                { "RoleId", "Role Id" },
                { "RoleDescription", "Role Description" },
                { "CreatedOn", "Created On" },
                { "CreatedBy", "Created By" },
                { "ModifiedOn", "Modified On" },
                { "ModifiedBy", "Modified By" }
            };

            // assign properties
            RoleMasterData       = objRoleMasterCol;
            RoleMasterFieldNames = fieldNames;
            TotalPages           = totalPages;
            CurrentPage          = currentPage;
            FieldToSort          = String.IsNullOrEmpty(sidx) ? "RoleId" : sidx;
            FieldSortOrder       = String.IsNullOrEmpty(sord) ? "asc" : sord;
            FieldToSortWithOrder = String.IsNullOrEmpty(sidx) ? "RoleId" : (sidx + " " + sord).Trim();
            NumberOfPagesToShow  = numberOfPagesToShow;
            StartPage            = Functions.GetPagerStartPage(currentPage, numberOfPagesToShow, totalPages);
            EndPage = Functions.GetPagerEndPage(StartPage, currentPage, numberOfPagesToShow, totalPages);
        }
        /// <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  = RoleMaster.GetRecordCount();
            int startRowIndex = ((_page * rows) - rows);
            List <RoleMaster> objRoleMasterCol = RoleMaster.SelectSkipAndTake(rows, startRowIndex, sidx + " " + sord);
            int totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows);

            if (objRoleMasterCol is null)
            {
                return(new JsonResult("{ total = 0, page = 0, records = 0, rows = null }"));
            }

            var jsonData = new
            {
                total = totalPages,
                _page,
                records = totalRecords,
                rows    = (
                    from objRoleMaster in objRoleMasterCol
                    select new
                {
                    id = objRoleMaster.RoleId,
                    cell = new string[] {
                        objRoleMaster.RoleId.ToString(),
                        objRoleMaster.RoleDescription,
                        objRoleMaster.CreatedOn.ToString("d"),
                        objRoleMaster.CreatedBy,
                        objRoleMaster.ModifiedOn.HasValue ? objRoleMaster.ModifiedOn.Value.ToString("d") : "",
                        objRoleMaster.ModifiedBy
                    }
                }).ToArray()
            };

            return(new JsonResult(jsonData));
        }
Пример #3
0
 /// <summary>
 /// Shows how to get the total number of records
 /// </summary>
 private void GetRecordCount()
 {
     // get the total number of records in the RoleMaster table
     int totalRecordCount = RoleMaster.GetRecordCount();
 }