private SearchResult <SysInfoSearchUIModel> GetSearchResult(SysInfoSearchModel model) { int pos = model.posStart.HasValue ? model.posStart.Value : 0; int count = model.count.HasValue ? model.count.Value : 30; var predicate = PredicateBuilder.True <t_bp_PkpmJCRU>(); if (!string.IsNullOrEmpty(model.InformationName)) { predicate = predicate.And(t => t.name.Contains(model.InformationName));//.Contains(t.name)); } string sortProperty = "addtime"; PagingOptions <t_bp_PkpmJCRU> pagingOption = new PagingOptions <t_bp_PkpmJCRU>(pos, count, sortProperty, true); var information = rep.GetByConditionSort <SysInfoSearchUIModel>(predicate, r => new { r.ID, r.name, r.content, r.addtime }, pagingOption); return(new SearchResult <SysInfoSearchUIModel>(pagingOption.TotalItems, information)); }
public ActionResult Search(SysInfoSearchModel model) { var data = GetSearchResult(model); DhtmlxGrid grid = new DhtmlxGrid(); var buttons = GetCurrentUserPathActions(); int pos = model.posStart.HasValue ? model.posStart.Value : 0; grid.AddPaging(data.TotalCount, pos); for (int i = 0; i < data.Results.Count; i++) { var information = data.Results[i]; DhtmlxGridRow row = new DhtmlxGridRow(information.Id.ToString()); row.AddCell(pos + i + 1); row.AddCell(information.Name); row.AddCell(information.Content); row.AddCell(GetUIDtString(information.Time)); if (HaveButtonFromAll(buttons, "Edit")) { row.AddCell(new DhtmlxGridCell("编辑", false).AddCellAttribute("title", "编辑")); } else { row.AddCell(string.Empty); } if (HaveButtonFromAll(buttons, "Delete")) { row.AddCell(new DhtmlxGridCell("删除", false).AddCellAttribute("title", "删除")); } else { row.AddCell(string.Empty); } grid.AddGridRow(row); } string str = grid.BuildRowXml().ToString(System.Xml.Linq.SaveOptions.DisableFormatting); return(Content(str, "text/xml")); }