ASP.NET Zero--14.一个例子(7)商品分类管理-分类搜索及分页
分类搜索实现
1.添加搜索框
...
<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">
...

2.搜索点击事件
//新建分类点击事件
$('#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()
});
}
}
3.创建Dto
public class GetCategoriesInput : PagedAndSortedInputDto, IShouldNormalize
{
public string Filter { get; set; }
public void Normalize()
{
if (string.IsNullOrEmpty(Sorting))
{
Sorting = "Name";
}
}
}
4.修改方法
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())
);
}
5.测试

表格分页实现
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)商品分类管理-分类搜索及分页的更多相关文章
- [asp.net core]SignalR一个例子
摘要 在一个后台管理的页面想实时监控一些操作的数据,想到用signalR. 一个例子 asp.net core+signalR 使用Nuget安装包:Microsoft.AspNetCore.Sign ...
- ASP.NET Zero--13.一个例子(6)商品分类管理-删除分类
1.添加按钮 首先添加一个删除按钮,打开文件Index.js[..\MyCompanyName.AbpZeroTemplate.Web\Areas\Mpa\Views\Category\Index.j ...
- ASP.NET Zero--8.一个例子(1)菜单添加
以一个商品分类管理功能来编写,代码尽量简单易懂.从一个实体开始,一直到权限控制,由浅到深一步步对功能进行完善. 1.打开语言文件 [..\MyCompanyName.AbpZeroTemplate.C ...
- 这算是ASP.NET MVC的一个大BUG吗?
这是昨天一个同事遇到的问题,我觉得这是一个蛮大的问题,而且不像是ASP.NET MVC的设计者有意为之,换言之,这可能是ASP.NET MVC的一个Bug(不过也有可能是保持原始请求数据而作的妥协). ...
- 从一个例子中体会React的基本面
[起初的准备工作] npm init npm install --save react react-dom npm install --save-dev html-webpack-plugin web ...
- Http,Https (SSL)的Url绝对路径,相对路径解决方案Security Switch 4.2 中文帮助文档 分类: ASP.NET 2014-10-28 14:09 177人阅读 评论(1) 收藏
下载地址1:https://securityswitch.googlecode.com/files/SecuritySwitch%20v4.2.0.0%20-%20Binary.zip 下载地址2:h ...
- [ASP.NET MVC2 系列] ASP.Net MVC教程之《在15分钟内用ASP.Net MVC创建一个电影数据库应用程序》
[ASP.NET MVC2 系列] [ASP.NET MVC2 系列] ASP.Net MVC教程之<在15分钟内用ASP.Net MVC创建一个电影数据库应用程序> ...
- 《The art of software testing》的一个例子
这几天一直在看一本书,<The art of software testing>,里面有一个例子挺有感触地,写出来和大家分享一下: [问题] 从输入对话框中读取三个整数值,这三个整数值代表 ...
- 一个例子读懂 JS 异步编程: Callback / Promise / Generator / Async
JS异步编程实践理解 回顾JS异步编程方法的发展,主要有以下几种方式: Callback Promise Generator Async 需求 显示购物车商品列表的页面,用户可以勾选想要删除商品(单选 ...
随机推荐
- Persistent Bookcase
Persistent Bookcase time limit per test 2 seconds memory limit per test 512 megabytes input standard ...
- JS传递到后台中文 出现乱码问题
js 异步传递中文字符,后台接收出现乱码问题 function showFirSelect(a){ var b = encodeURI(a); var secUrl = "<%=bas ...
- Java内存回收 - 落日之心的日志 - 网易博客
body{ font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI& ...
- Sping--Id, Name
bean, id/name 都可以 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns=& ...
- linux 驱动入门5
慢慢的开始转驱动,目前比较有时间,一定要把驱动学会.哎.人生慢慢路,一回头.已经工作了八九年了.努力.在买套房.改退休了.学驱动.个人认为首先要熟悉驱动框架.慢慢来.心急吃不了热豆腐. 看网上都说的设 ...
- codeforces #321 DIV2
A题: 链接:http://codeforces.com/contest/580/problem/A dp,最长连续不上升子序列 #include<iostream> #include&l ...
- STM32单片机图片解码
图片解码首先是最简单的bmp图片解码,关于bmp的结构可自行查阅,代码如下 #ifndef __BMPDECODE_H_ #define __BMPDECODE_H_ #include "f ...
- 起步X5 的铛铛的安装部署过程
(2017年1月)主要资料: 1.铛铛的IM Server即时通信服务使用 actor https://github.com/actorapp/actor-platform ,开发者网站是:htt ...
- 用weka来做Logistic Regression
1.首先下载安装weka http://www.cs.waikato.ac.nz/ml/weka/downloading.html 2.打开weka,选择第一项Explorer 3.准备数据集文件,在 ...
- [noip2013]货车运输(kruskal + 树上倍增)
描述 A 国有 n 座城市,编号从 1 到 n,城市之间有 m 条双向道路.每一条道路对车辆都有重量限制,简称限重.现在有 q 辆货车在运输货物,司机们想知道每辆车在不超过车辆限重的情况下,最多能运多 ...