... <div class="portlet light"> <div class="portlet-title portlet-title-filter"> <div class="inputs inputs-full-width"> <div class="portlet-input"> <form> <div class="input-group"> <input id="CategoriesTableFilter" class="form-control" placeholder="@L("SearchWithThreeDot")" type="text" value="@ViewBag.FilterText"> <span class="input-group-btn"> <button id="GetCategoriesButton" class="btn default" type="submit"><i class="icon-magnifier"></i></button> </span> </div> </form> </div> </div> </div> <div class="portlet-body"> ...
//新建分类点击事件 $(‘#CreateNewCategoryButton‘).click(function () { _createModal.open(); }); //搜索点击事件 $(‘#GetCategoriesButton‘).click(function (e) { //取消事件的默认动作 e.preventDefault(); getCategories(); });
function getCategories(reload) { if (reload) { _$categoriesTable.jtable(‘reload‘); } else { _$categoriesTable.jtable(‘load‘, { filter: $(‘#CategoriesTableFilter‘).val() }); } }
public class GetCategoriesInput : PagedAndSortedInputDto, IShouldNormalize { public string Filter { get; set; } public void Normalize() { if (string.IsNullOrEmpty(Sorting)) { Sorting = "Name"; } } }
PagedResultOutput<CategoryOutput> GetCategories(GetCategoriesInput input);
public PagedResultOutput<CategoryOutput> GetCategories(GetCategoriesInput input) { //创建映射 Mapper.CreateMap<Category, CategoryOutput>(); var result=_categoryRepository.GetAll(); if (!string.IsNullOrWhiteSpace(input.Filter)) { result=result.Where(a => a.Name.Contains(input.Filter)); } int totalCount = result.Count(); return new PagedResultOutput<CategoryOutput>( totalCount, Mapper.Map<List<CategoryOutput>>(result.ToList()) ); }
public PagedResultOutput<CategoryOutput> GetCategories(GetCategoriesInput input) { //创建映射 Mapper.CreateMap<Category, CategoryOutput>(); var result=_categoryRepository.GetAll(); if (!string.IsNullOrWhiteSpace(input.Filter)) { result=result.Where(a => a.Name.Contains(input.Filter)); } int totalCount = result.Count(); var list=result.OrderBy(input.Sorting).PageBy(input).ToList();//分页 return new PagedResultOutput<CategoryOutput>( totalCount, Mapper.Map<List<CategoryOutput>>(list) ); }
ASP.NET Zero--14.一个例子(7)商品分类管理-分类搜索及分页
原文:http://www.cnblogs.com/shensigzs/p/6305795.html