datagrid在MVC中的运用02-结合搜索
2014-02-28 13:04
295 查看
本文接着上一篇,来体验给datagrid加上搜索功能。主要涉及到:
※ 把一个div与datagrid相关起来
※ datagrid接收查询参数
※ 查询参数的封装
效果图:
JsonSerializeHelper静态类在上一篇介绍过。
※ 把一个div与datagrid相关起来
※ datagrid接收查询参数
※ 查询参数的封装
效果图:
展开using System.Web; using System.Web.Mvc; using DataGridInMvc.Helper; using DataGridInMvc.Models; namespace DataGridInMvc.Controllers { public class HomeController : Controller { public ActionResult Index() { return View(); } // public ActionResult GetData() { //接收datagrid传来的参数 int pageIndex = int.Parse(Request["page"]); int pageSize = int.Parse(Request["rows"]); //接收搜索参数 string itemId = Request["ItemId"]; string productId = Request["ProductId"]; //构建得到分页数据方法所需的参数 var temp = new BookParam() { PageIndex = pageIndex, PageSize = pageSize, ItemId = itemId, ProductId = productId }; //分页数据方法的输出参数 int totalNum = 0; var service = new BookService(); var books = service.LoadPageBookData(temp, out totalNum); var result = from book in books select new {book.ItemId, book.ProductId, book.ListPrice, book.UnitCost, book.Status, book.Attr1}; //total,rows是前台datagrid所需要的 var jsonResult = new {total = totalNum, rows = result}; //把json对象序列化成字符串 string str = JsonSerializeHelper.SerializeToJson(jsonResult); return Content(str); } } }
JsonSerializeHelper静态类在上一篇介绍过。
相关文章推荐
- datagrid在MVC中的运用04-同时添加搜索和操作区域
- datagrid在MVC中的运用05-加入时间搜索条件,枚举填充下拉框
- Quartz.net 2.x 学习笔记02-Quartz.net 2.x在MVC站点中结合Log4net的使用
- datagrid在MVC中的运用06-固定连续列
- datagrid在MVC中的运用08-实现Master-Detail(使用子datagrid)
- AutoMapper在MVC中的运用02-Decimal转String、集合、子父类映射
- jQuery EasyUI DataGrid在MVC中的运用-基本属性并实现分页
- AutoMapper在MVC中的运用02
- datagrid在MVC中的运用09-实现排序
- datagrid在MVC中的运用03-选择单行或多行
- datagrid在MVC中的运用10-勾选
- datagrid在MVC中的运用01-基本属性并实现分页
- Push Posting 关键词搜索职位 - 结合搜索引擎广告
- hdu 4020 很好的set和结构体的结合运用 很帅的一个题啊
- Push Posting 关键词搜索职位 - 结合搜索引擎广告
- MVC入门小示例---淘宝商品的搜索和价格筛选
- easyui form datagrid getSelected的结合 | jquery的each方法
- swf上传控件在asp.net和MVC中的运用
- mvc 、bootstrap 结合分布式图简单实现分页
- UL-LI 标签结合CSS的运用