public IEnumerable <tbl_MCE_Function> FunctionList(FunctionSearchPanel functionSearchPanel) { DynamicParameters param = new DynamicParameters(); param.Add("@P_CHRACTION", "FUNCTIONALLSP"); if (functionSearchPanel.vchFunctionName != null) { param.Add("@P_vchFunctionName", functionSearchPanel.vchFunctionName); } if (functionSearchPanel.vchDescription != null) { param.Add("@P_vchDescription", functionSearchPanel.vchDescription); } return(DapperORM.ReturnList <tbl_MCE_Function>("SP_MCE_Function_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 GetFunctionForSearchPanel(FunctionSearchPanel functionSearchPanel) { //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 functionList = (from a in _function.FunctionList(functionSearchPanel) select a); //SORT //if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDir))) //{ // functionList = functionList.OrderBy(sortColumn + " " + sortColumnDir); //} recordsTotal = functionList.Count(); var data = functionList.Skip(skip).Take(pageSize).ToList(); return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = data }, JsonRequestBehavior.AllowGet)); }