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 需求 显示购物车商品列表的页面,用户可以勾选想要删除商品(单选 ...
随机推荐
- Sublime 2 配置
在队友的推荐下,爱上了这款神一样的文本编辑器,熟练之后编辑效率真心是大幅提升啊. 一.Package Control Sublime拥有很强大的插件功能,而自带的缺少个管理工具,这个包可以用来很方便地 ...
- 实战3--项目开始--准备:::资源分类, 日志系统, 写BaseDao
项目资源分类: 1. package: base, dao, dao.impl, domain, service, service.impl, util, view.action 2. co ...
- iOS常用宏定义
转发:https://www.douban.com/note/486674206/ #ifndef MacroDefinition_h#define MacroDefinition_h //----- ...
- Linux挂在ntfs格式的U盘
工作中遇到linux系统 Red Hat Enterprise5.7 挂载希捷ntfs格式移动硬盘,会跳出一个ERROR提示框:The volume ‘EAGET-NQH’user the ntfs ...
- 基于LNMP的Zabbbix之Zabbix Server源码详细安装,但不给图
Zabbix Server安装 看到那里有错或者有什么问题的话,求指点 邮箱:losbyday@163.com 上一篇PHP源码安装参见基于LNMP的Zabbbix之PHP源码安装:https://i ...
- IT技术网站汇总
首先是比较著名的博客型的网站!一般来说在国外比较著名的博客基本上都是比较有影响力发起的或者建立的经常发布一些比较有思考力深入分析的文章! 博客媒体网站 1.www.ArsTechnica.com 2. ...
- 对AD域进行定期自动备份设置图解
今天为大家讲解一下,如何对域进行定期的备份,因为如果域出问题了,在公司里那可就不好玩了啊,对做定期备份,在域出问题的时候可以及时恢复,减少对域重建而浪费大量的时间,同样也耽误公司员工的工作,这样的事情 ...
- Dom编程(二)
document是window对象的一个属性,因为使用window对象成员的时候可以省略window.,所以一般直接写document document的方法: (1)write:向文档中写入内容. ...
- 【bug】java.lang.NoSuchMethodError: android.widget.TextView.setBackground
安卓的背景色设置需要根据SDK的版本来分情况考虑: if (Build.VERSION.SDK_INT >= 16) { textView.setBackground(null); } else ...
- javascript---jquery (1事件)
1.例子说明 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. ...