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 需求 显示购物车商品列表的页面,用户可以勾选想要删除商品(单选 ...
随机推荐
- 一个action读取另一个action里的session
action 1: private Map session; session.put("projectname_session", request1.getParameter(&q ...
- java中基本数据类型和C语言中基本数据类型转换
java中 1 short = 2 byte 1 char = 2 byte 1 int = 4 byte 1 long = 8 byte C语言中 typedef unsigned char ...
- smali插入log,打印变量
一:Log打印变量: Log打印字符串: #liyanzhong debug const-string v1, "TAG" const-string v2, "xunbu ...
- CodeForces 610C Harmony Analysis
构造 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> us ...
- ARM架构解析
ARM架构解析 (2014-11-23 21:56:53) 转载▼ 标签: francis_hao arm架构 arm核 soc 分类: MCU 先来谈一下ARM的发展史:1978年12月5日,物理学 ...
- With PHP frameworks, why is the “route” concept used?
http://programmers.stackexchange.com/questions/122190/with-php-frameworks-why-is-the-route-concept-u ...
- Redis 代理 twemproxy
4台 redis 服务器 172.16.1.37:6379 - 1 172.16.1.36:6379 - 2 172.16.1.35:6379 - 3 172.16.1.34:6379 ...
- /bin/sh 与 /bin/bash 的区别
/bin/sh 与 /bin/bash 的区别,用 : 截取字符串不是POSIX 标准的. 区别 sh 一般设成 bash 的软链 (symlink) ls -l /bin/sh lrwxrwxrwx ...
- cocopods安装与使用
转自http://www.cnblogs.com/jys509/p/4839803.html Cocoapods安装步骤 1.升级Ruby环境 sudo gem update --system 如果R ...
- MYSQL一次性能优化实战经历[转]
每次经历数据库性能调优,都是对性能优化的再次认识.对自己知识不足的有力验证,只有不断总结.学习才能少走弯路. 一.性能问题描述 应用端反应系统查询缓慢,长时间出不来结果.SQLServer数据库服务器 ...