分享在MVC3.0中使用jQuery DataTable 插件
来源:互联网 发布:网页页面设计软件 编辑:程序博客网 时间:2024/04/27 11:28
http://www.cnblogs.com/ryanding/archive/2011/02/18/1957318.html
官方网站
http://datatables.net/
MVC3.0中使用JQuery.DataTable插件
http://biancheng.dnbcw.info/net/350648.html
官方网站
http://datatables.net/
HomeControllerpublic ActionResult GetJsonCitys(int? secho) { var cityList = new List<Citys>(); for (int i = 0; i < 100; i++) { cityList.Add(new Citys { Id = i, CityName = Guid.NewGuid().ToString(), ZipCode = DateTime.Now.Millisecond }); } var objs = new List<object>(); foreach (var city in cityList) { objs.Add(GetPropertyList(city).ToArray()); } return Json(new { sEcho = secho, iTotalRecords = cityList.Count(), aaData = objs }, JsonRequestBehavior.AllowGet); } private List<string> GetPropertyList(object obj) { var propertyList = new List<string>(); var properties = obj.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (var property in properties) { object o = property.GetValue(obj, null); propertyList.Add(o == null ? "" : o.ToString()); } return propertyList; }
<span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"><table class="display" id="DataTable"></span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> <thead></span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> <tr></span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> <th></span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> Id</span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> </th></span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> <th></span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> CityName</span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> </th></span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> <th></span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> ZipCode</span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> </th></span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> <th></span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> 操作</span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> </th></span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> </tr></span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> </thead></span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> <tbody></span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> </tbody></span><br style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);" /><span style="font-family: Simsun; font-size: 14px; line-height: 25px; background-color: rgb(244, 251, 244);"> </table></span>
<script type="text/javascript" charset="utf-8"> $(document).ready(function () { $('#DataTable').dataTable({ "oLanguage": {//语言国际化 "sUrl": "/Scripts/Plug-in/jquery.dataTable.cn.txt" }, "bJQueryUI": true, "sPaginationType": "full_numbers", 'bPaginate': true, //是否分页。 "bProcessing": true, //当datatable获取数据时候是否显示正在处理提示信息。 "bServerSide": false, "sAjaxSource": "Home/GetJsonCitys", "aoColumns": [ { "sTitle": "编号", "sClass": "center" }, { "sTitle": "城市名称", "sClass": "center" }, { "sTitle": "邮政编码", "sClass": "center" }, { "sTitle": "操作", "sClass": "center", "fnRender": function (obj) { return '<a href=\"Details/' + obj.aData[0] + '\">查看详情</a> <input tag=\"' + obj.aData[0] + '\" type=\"checkbox\" name=\"name\" />'; } } ] }); });
0 0
- 分享在MVC3.0中使用jQuery DataTable 插件
- 分享在MVC3.0中使用jQuery DataTable 插件
- 分享在MVC3.0中使用jQuery DataTable 插件
- jquery datatable插件使用分享
- 在asp.net mvc3 中使用autocomplete jquery ui
- 在asp.net mvc3中使用combogrid jquery easy ui
- 在MVC3.0中使用Ckeditor【鸡蛋】
- 在MVC3中使用UserData
- 基于jquery的上传插件Uploadify 3.1.1在MVC3中的使用
- 在MVC3中使用jquery及jquery.form.js来提交表单
- [总结] jQuery的datatable插件 使用 问题
- Jquery DataTable插件使用(1)
- JQuery表格插件DataTable的使用
- 在struts2中使用jQuery插件ajaxfileupload
- 在MVC3中jQuery的ajax使用无效,原因在于路径
- 关于JQUERY的DataTable插件的使用过程笔记【持续更新中……】
- 【jQuery】datatable插件
- jQuery datatable 插件用法
- hdu 3593
- C++ class与内存
- LeetCode(141)(142) Linked List Cycle I II
- Linux - 有效群组(effective group)与初始群组(initial group),groups,newgrp
- 高仿SinaWeibo新浪微博发布页面话题效果
- 分享在MVC3.0中使用jQuery DataTable 插件
- FileOutputStream/FileInputStream--FileWriter/FileReader
- 相似图片搜索
- 提示磁盘被写保护怎么办?
- Python中re(正则表达式)模块详解
- 项目开发中用到的一些MySQL语句
- hdu 4547 lca-tarjan离线算法
- 属性名前两个字母要么都是大写的要么都是小写的(当然数字与_、$算小写)
- jQuery 动画、HTML、CSS