public IEnumerable <tbl_MCE_Branch> BranchList(BranchSearchPanel branchSearchPanel) { DynamicParameters param = new DynamicParameters(); param.Add("@P_CHRACTION", "BRANCHALLSP"); if (branchSearchPanel.intCourseID != 0 && branchSearchPanel.intCourseID != null) { param.Add("@P_intCourseID", branchSearchPanel.intCourseID); } if (branchSearchPanel.vchBranchDescription != null) { param.Add("@P_vchBranchDescription", branchSearchPanel.vchBranchDescription); } return(DapperORM.ReturnList <tbl_MCE_Branch>("SP_MCE_Branch_Report", param)); }
//This post method calls in View page thorough AJax call to bind the data in JQuery Datatable //Server side processing concept used to bind the data in JQuery public ActionResult GetBranchForSearchPanel(BranchSearchPanel branchSearchPanel) { //Note: Install "System.Linq.Dynamic" from Nuget Packages // after this just include namespace in our Controller "using System.Linq.Dynamic;". //Draw counter. This is used by DataTables to ensure that the Ajax returns from server-side processing requests are drawn in sequence by DataTables (Ajax requests are asynchronous and thus can return out of sequence). var draw = Request.Form.GetValues("draw").FirstOrDefault(); //Paging first record indicator. This is the start point in the current data set (0 index based - i.e. 0 is the first record) var start = Request.Form.GetValues("start").FirstOrDefault(); //Number of records that the table can display in the current draw. var length = Request.Form.GetValues("length").FirstOrDefault(); //Find Order Column var sortColumn = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault(); var sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault(); int pageSize = length != null?Convert.ToInt32(length) : 0; int skip = start != null?Convert.ToInt32(start) : 0; int recordsTotal = 0; var branchList = (from a in _branches.BranchList(branchSearchPanel) select a); ////SORT //if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDir))) //{ // branchList = branchList.OrderBy(sortColumn + " " + sortColumnDir); //} recordsTotal = branchList.Count(); var data = branchList.Skip(skip).Take(pageSize).ToList(); return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = data }, JsonRequestBehavior.AllowGet)); }