public static string GetFiltering <T>(this KendoGridRequest request) { var finalExpression = ""; foreach (var filterObject in request.FilterObjectWrapper.FilterObjects) { if (finalExpression.Length > 0) { finalExpression += " " + request.FilterObjectWrapper.LogicToken + " "; } if (filterObject.IsConjugate) { var expression1 = GetExpression <T>(filterObject.Field1, filterObject.Operator1, filterObject.Value1); var expression2 = GetExpression <T>(filterObject.Field2, filterObject.Operator2, filterObject.Value2); var combined = string.Format("({0} {1} {2})", expression1, filterObject.LogicToken, expression2); finalExpression += combined; } else { var expression = GetExpression <T>(filterObject.Field1, filterObject.Operator1, filterObject.Value1); finalExpression += expression; } } if (finalExpression.Length == 0) { return("true"); } return(finalExpression); }
public JsonResult AjaxBinding(KendoGridRequest request, string keyWord, string downloadClassId) { SetConditions(keyWord, downloadClassId); var data = GetGridData(); var result = new KendoGrid<DownloadRecord>(request, data.Skip((request.Page - 1) * request.PageSize).Take(request.PageSize), data.Count()); return Json(result); }
private void AppendSortingCondition(KendoGridRequest request) { if (request.SortObjects.Count() == 1) { SortObject sortObject = request.SortObjects.FirstOrDefault(); string field = sortObject.Field.Replace("GetStr_", ""); string direction = sortObject.Direction; m_Conditions.Add("Order", string.Format("order by d.{0} {1}", field, direction)); } }
public JsonResult AdditionalLinks(KendoGridRequest request) { var employees = new List<AdditionalLinks> { new AdditionalLinks { Id = 1, Name = "Bill", Url= "Jones"}, new AdditionalLinks { Id = 2, Name = "Rob", Url = "Johnson"}, new AdditionalLinks { Id = 3, Name = "Jane", Url = "Smith"}, }; var grid = new KendoGrid<AdditionalLinks>(request, employees); return Json(grid); }
public JsonResult AjaxBinding(KendoGridRequest request, string keyWord, string downloadClassId, string memberLoginId) { SetConditions(keyWord, downloadClassId, memberLoginId); int total = GetGridTotal(); int pageIndex = (request.Page - 1); m_Conditions.Add("PageIndex", pageIndex.ToString()); m_Conditions.Add("PageSize", request.PageSize.ToString()); AppendSortingCondition(request); var data = GetGridData(); var result = new KendoGrid<DownloadRecord>(request, data, total); return Json(result); }
public JsonResult Grid(KendoGridRequest request) { var fromdb = ((Log)_table).All(); var dto = fromdb.Select(x => new LogDto { UpdatedAt = x.UpdatedAt, IpAddress = x.IpAddress, Level = x.Level, Server = x.Server, Session=x.Session, UserName= x.UserName, Summary = x.Summary, Id = x.Id, Email = x.Email }).OrderByDescending(x => x.UpdatedAt); var grid = new KendoGrid<LogDto>(request, dto); return Json(grid); }
/// <summary> /// KendoGrid constructor - IEnumerable set, will evaluate set AsQueryable() /// </summary> /// <param name="request">KendoGridRequest object</param> /// <param name="list">IEnumerable set representing a page of data</param> public KendoGrid(KendoGridRequest request, IEnumerable <T> list) { var filtering = request.GetFiltering <T>(); var sorting = request.GetSorting(); Data = list.AsQueryable() .Where(filtering) .OrderBy(sorting).ToList(); Total = Data.Count(); Data = Data .Skip(request.Skip) .Take(request.Take); }
public JsonResult GetCustomer(KendoGridRequest request) { try { var result = db.Customers.ToList(); return Json(new KendoGrid<Customers>(request, result), JsonRequestBehavior.AllowGet); } catch (Exception) { Dictionary<string, object> error = new Dictionary<string, object>(); error.Add("ErrorCode", -1); error.Add("ErrorMessage", "讀取資料失敗!"); return Json(error); } }
public JsonResult Grid(KendoGridRequest request) { var fromdb = ((Projects)_table).All(); var dto = fromdb.Select(x => new ProjectsDto { Id = x.Id, UpdatedAt = x.UpdatedAt, Name = x.Name /*FirstName = x.FirstName, LastName = x.LastName, Email = x.Email, Level = x.Level, Server = x.Server, UserName= x.UserName, Summary = x.Summary, Email = x.Email*/ }).OrderByDescending(x => x.UpdatedAt); var grid = new KendoGrid< ProjectsDto>(request, dto); return Json(grid); }
/// <summary> /// KendoGrid constructor - IQueryable set /// </summary> /// <param name="request">KendoGridRequest object</param> /// <param name="query">IQueryable object representing unrealized set of data</param> public KendoGrid(KendoGridRequest request, IQueryable <T> query) { // call another method here to get filtering and sorting. var filtering = request.GetFiltering <T>(); var sorting = request.GetSorting(); var tempQuery = query .Where(filtering) .OrderBy(sorting); Total = tempQuery .Count(); Data = tempQuery .Skip(request.Skip) .Take(request.Take); }
public static string GetSorting(this KendoGridRequest request) { var expression = ""; foreach (var sortObject in request.SortObjects) { expression += sortObject.Field + " " + sortObject.Direction + ", "; } if (expression.Length < 2) { return("true"); } expression = expression.Substring(0, expression.Length - 2); return(expression); }
public JsonResult Grid(KendoGridRequest request) { var fromdb = ((Customer)_table).All(); var dto = fromdb.Select(x => new CustomerDto { Id = x.Id, UpdatedAt = x.UpdatedAt, IpAddress = x.IpAddress, Session = x.Session, City = "xxxxxxxxx", State = "xxxxxxxxx", Zip = "xxxxxxxxx", FirstName = x.FirstName, LastName = x.LastName, Email = x.Email }).OrderByDescending(x => x.UpdatedAt); var grid = new KendoGrid< CustomerDto>(request, dto); return Json(grid); }
public JsonResult Grid(KendoGridRequest request) { var fromdb = ((Product)_table).All(); var dto = fromdb.Select(x => new ProductDto { Id = x.Id, UpdatedAt = x.UpdatedAt, Title = x.Title, Price = x.Price, MemberPrice = x.MemberPrice, ImageUrl = "/Public/images/picture2.jpg" /*IpAddress = x.IpAddress, Session = x.Session, FirstName = x.FirstName, LastName = x.LastName, Email = x.Email, Level = x.Level, Server = x.Server, UserName= x.UserName, Summary = x.Summary, Email = x.Email*/ }).OrderByDescending(x => x.UpdatedAt); var grid = new KendoGrid< ProductDto>(request, dto); return Json(grid); }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { if (bindingContext == null) { throw new ArgumentNullException("bindingContext"); } _request = controllerContext.HttpContext.Request; var take = Convert.ToInt32(GetQueryStringValue("take")); var page = Convert.ToInt32(GetQueryStringValue("page")); var skip = Convert.ToInt32(GetQueryStringValue("skip")); var pageSize = Convert.ToInt32(GetQueryStringValue("pageSize")); var filterLogic = GetQueryStringValue("filter[logic]"); var sortKeys = (from x in GetRequestKeys() where x.StartsWith("sort") select x).ToList(); var filterKeys = (from x in GetRequestKeys() where x.StartsWith("filter") && x != "filter[logic]" select x).ToList(); var filtering = GetFilterObjects(filterKeys, filterLogic); var sorting = GetSortObjects(sortKeys); var gridObject = new KendoGridRequest { Take = take, Skip = skip, Page = page, PageSize = pageSize, FilterObjectWrapper = filtering, SortObjects = sorting }; return(gridObject); }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { if (bindingContext == null) throw new ArgumentNullException("bindingContext"); _request = controllerContext.HttpContext.Request; var take = Convert.ToInt32(GetQueryStringValue("take")); var page = Convert.ToInt32(GetQueryStringValue("page")); var skip = Convert.ToInt32(GetQueryStringValue("skip")); var pageSize = Convert.ToInt32(GetQueryStringValue("pageSize")); var filterLogic = GetQueryStringValue("filter[logic]"); var sortKeys = (from x in GetRequestKeys() where x.StartsWith("sort") select x).ToList(); var filterKeys = (from x in GetRequestKeys() where x.StartsWith("filter") && x != "filter[logic]" select x).ToList(); var filtering = GetFilterObjects(filterKeys, filterLogic); var sorting = GetSortObjects(sortKeys); var gridObject = new KendoGridRequest { Take = take, Skip = skip, Page = page, PageSize = pageSize, FilterObjectWrapper = filtering, SortObjects = sorting }; return gridObject; }
private static void CheckPageSize(KendoGridRequest gridRequest, int pagesize) { Assert.IsNotNull(gridRequest.PageSize); Assert.AreEqual(pagesize, gridRequest.PageSize.Value); }
public void UpdateAdditionalLinks(KendoGridRequest request) { }
public JsonResult AjaxBinding(KendoGridRequest request, string enterTimeFrom, string enterTimeTo) { SetConditions(enterTimeFrom, enterTimeTo); int total = GetGridTotal(); int pageIndex = (request.Page - 1); m_Conditions.Add("PageIndex", pageIndex.ToString()); m_Conditions.Add("PageSize", request.PageSize.ToString()); AppendSortingCondition(request); var data = GetGridData(); var result = new KendoGrid<MasterLog>(request, data, total); return Json(result); }
public KendoGrid(KendoGridRequest request, IEnumerable <TModel> list) : this(request, list.AsQueryable()) { }
public JsonResult AjaxBinding(KendoGridRequest request, string keyWord) { SetConditions(keyWord); int total = GetGridTotal(); int pageIndex = (request.Page - 1); m_Conditions.Add("PageIndex", pageIndex.ToString()); m_Conditions.Add("PageSize", request.PageSize.ToString()); AppendSortingCondition(request); var data = GetGridData(); var result = new KendoGrid<Activity>(request, data, total); return Json(result); }
public JsonResult AjaxBinding(KendoGridRequest request, string templateType) { var data = GetGridData(templateType); var result = new KendoGrid<TemplateVO>(request, data.Skip((request.Page - 1) * request.PageSize).Take(request.PageSize), data.Count()); return Json(result); }
public KendoGrid(KendoGridRequest request, IQueryable <TModel> query) : base(request, query, null, null) { }
public JsonResult CategoryGrid(KendoGridRequest request) { db.Configuration.ProxyCreationEnabled = false; var categories = (from c in db.Categories orderby c.OrderBy, c.Name select new CategoryForIndex { WorkCategoryId = c.WorkCategoryId, Name = c.Name, OrderBy = c.OrderBy }).ToList(); var grid = new KendoGrid<CategoryForIndex>(request, categories); return Json(grid); }
public JsonResult GetEmployeeNameList(KendoGridRequest request) { db.Configuration.ProxyCreationEnabled = false; if (User.IsInRole("工程師")) { return Json("{}"); } else { var employee = db.Employees.ToList(); var grid = new KendoGrid<Employee>(request, employee); return Json(grid); } }
public JsonResult Grid(KendoGridRequest request) { db.Configuration.ProxyCreationEnabled = false; var employees = (from e in db.Employees.Include("Rank") select new RankInfoForEmployee { EmployeeId = e.EmployeeId, Account = e.Account, Name = e.Name, Email = e.Email, Rank = e.Rank.Name, Company = e.Company, RecvNotify = e.RecvNotify, Activity = e.Activity, CreateDate = e.CreateDate, LastLoginDate = e.LastLoginDate }).ToList(); var grid = new KendoGrid<RankInfoForEmployee>(request, employees); return Json(grid); }
private static void CheckSkip(KendoGridRequest gridRequest, int skip) { Assert.IsNotNull(gridRequest.Skip); Assert.AreEqual(skip, gridRequest.Skip.Value); }
public JsonResult AjaxBinding(KendoGridRequest request, string keyWord, string company, string companyTrade, string companyNationality, string companyScale, string companyType, string isAA1000, string isGRI, string postYearFrom, string postYearTo, string reportYearFrom, string reportYearTo) { SetConditions(keyWord, company, companyTrade, companyNationality, companyScale, companyType, isAA1000, isGRI, postYearFrom, postYearTo, reportYearFrom, reportYearTo); int total = GetGridTotal(); int pageIndex = (request.Page - 1); m_Conditions.Add("PageIndex", pageIndex.ToString()); m_Conditions.Add("PageSize", request.PageSize.ToString()); AppendSortingCondition(request); var data = GetGridData(); var result = new KendoGrid<Report>(request, data, total); return Json(result); }
private static void CheckTake(KendoGridRequest gridRequest, int take) { Assert.IsNotNull(gridRequest.Take); Assert.AreEqual(take, gridRequest.Take.Value); }
public JsonResult Grid(KendoGridRequest request) { var posts = _postRepository.All; Mapper.CreateMap<Post, GridPost>(); var list = Mapper.Map<IEnumerable<GridPost>>(posts); var grid = new KendoGrid<GridPost>(request, list); return Json(grid); }
public JsonResult Grid(KendoGridRequest request) { db.Configuration.ProxyCreationEnabled = false; var projects = db.Projects.Include("Predictions").OrderByDescending(d => d.StartOn).ToList(); foreach (var x in projects) { if (x.ProjectNo == null) x.ProjectNo = ""; if (x.CustomerCode == null) x.CustomerCode = ""; if (x.CustomerName == null) x.CustomerName = ""; } var grid = new KendoGrid<Project>(request, projects); return Json(grid); }
public JsonResult Grid(KendoGridRequest request) { // Sample here: https://github.com/rwhitmire/KendoGridBinder db.Configuration.ProxyCreationEnabled = false; var emp = db.Employees.Include("Rank").Where(e => e.Account == User.Identity.Name).FirstOrDefault(); List<DailyInfoForIndex> dailies = new List<DailyInfoForIndex>(); if (emp.Rank.Name == "工程師") { dailies = (from d in db.Dailies.Include("WorkCategory").Include("Project") where d.EmployeeId == emp.EmployeeId select new DailyInfoForIndex { DailyInfoId = d.DailyInfoId, CreateDate = d.CreateDate, EmployeeId = d.DailyInfoId, Customer = d.Project.CustomerName, ProjectNo = d.Project.ProjectNo, WorkContent = d.WorkContent, WorkingHours = d.WorkingHours, WorkCategory = d.WorkCategory.Name, EmployeeName = d.Employee.Name }).OrderByDescending(d => d.CreateDate).ToList(); } else { dailies = (from d in db.Dailies.Include("WorkCategory").Include("Project") select new DailyInfoForIndex { DailyInfoId = d.DailyInfoId, CreateDate = d.CreateDate, EmployeeId = d.DailyInfoId, Customer = d.Project.CustomerName, ProjectNo = d.Project.ProjectNo, WorkContent = d.WorkContent, WorkingHours = d.WorkingHours, WorkCategory = d.WorkCategory.Name, EmployeeName = d.Employee.Name }).OrderByDescending(d => d.CreateDate).ToList(); foreach (var daily in dailies) { if (daily.ProjectNo == null) daily.ProjectNo = ""; } } var grid = new KendoGrid<DailyInfoForIndex>(request, dailies); return Json(grid); }