http://www.cnblogs.com/ryanding/archive/2011/02/18/1957318.html

MVC3.0中使用JQuery.DataTable插件

http://biancheng.dnbcw.info/net/350648.html

官方网站
http://datatables.net/

HomeController
public 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\" />';}}]});});

转载于:https://www.cnblogs.com/sui84/p/6777037.html

分享在MVC3.0中使用jQuery DataTable 插件相关推荐

  1. MVC3.0中使用JQuery.DataTable插件。

    最近做项目的时候发现了一个很好的JQuery插件DataTable但是网上相关的资料好像很少,本人英文不咋滴在官网上除了知道点哪能下载外其它就都不知道鸟.后来用了个把小时写了个小demo,分享给大家, ...

  2. Vue CLI3.0 中使用jQuery 和 Bootstrap

    Vue 中使用 jQuery 和 Bootstrap 不是特别符合 Vue 原生的写法,但是有时候又要用,所以放上我的引入设置,供大家参考. 在 Vue CLI2.0 中引入 jQuery 和 Boo ...

  3. MVC3.0 中Razor 学习

    为什么80%的码农都做不了架构师?>>>    随着MVC3.0RTM版本的发布,最近将公司的项目从MVC2.0升级到MVC3.0.同时打算在MVC3中全面使用Razor模板引擎.现 ...

  4. MVC3.0 中Razor 学习 cshtml文件

     随着MVC3.0RTM版本的发布,最近将公司的项目从MVC2.0升级到MVC3.0.同时打算在MVC3中全面使用Razor模板引擎.现将Razor学习拿出来和大家分享,如果存在不足的地方欢迎您指 ...

  5. 关于Vue2.0中引入jQuery

    1.npm i jquery -S 2.在vue.config.js(无该文件的在根目录创建该文件)中配置 添加configureWebpack中的内容 var webpack = require(& ...

  6. MVC3.0中直接在VS中浏览cshtml页面

    第一步:一般找到MVC中的项目,然后找到Views文件夹,一般中在其中有一个Login文件夹,找到index.cshtml文件. 如下图所示: 第二步:打开属性后,可以看到如下的图示: 特殊注意用红色 ...

  7. CentOS 6.3 64bit上测试ATS 5.3.0中的正则刷新插件regex_revalidate

    注意到ATS源码目录plugin/experimental/下面有regex_revalidate插件目录,我们在编译时添加--enable-experimental-plugins配置项就可以将其编 ...

  8. 分享一款超棒的jQuery旋钮插件 - jQuery knob

    转自:http://www.cnblogs.com/gbin1/archive/2012/05/08/2489908.html 在线演示  本地下载 如果你也在寻找一款生成漂亮旋钮(knob)的jQu ...

  9. ajax会占用服务器端内存吗,javascript - 为什么不允许在jquery datatable服务器端处理ajax成功使用? - 堆栈内存溢出...

    我正在使用asp.net mvc5并尝试使用jquery datatable插件服务器端处理. 服务器端处理的教程显示了从服务器返回结果的格式.但是我的项目的不同之处在于我无法从服务器发送" ...

最新文章

  1. 分治、动态规划、贪婪 之 算法分析
  2. linux 系统监控 php,Linux系统资源监控命令简介
  3. php实现隐藏字符串的功能
  4. Setup a Windows Server 2012 ×××
  5. 虚拟语气和推测(一)
  6. Rust FFI 编程--理解不同语言的数据类型转换
  7. 两个大数之间的乘积计算,string1=123456789...76,string2=23456...8957,求模拟计算机计算这两个数字的乘积。(C++实现)
  8. 烽火狼烟丨PHP远程代码执行漏洞(CVE-2022-31625、CVE-2022-31626)风险提示
  9. 严平稳随机过程,宽平稳随机过程,二阶矩过程之间的关系
  10. h5通过当前时间获取农历日期
  11. 验证码短信是如何实现的?怎么用短信平台发送验证码短信?
  12. TensorFlow从1到2(十一)变分自动编码器和图片自动生成
  13. 如何在 Linux 系统中添加桌面图标
  14. ubuntu 使用GParted对Ubuntu /dev/sda1进行磁盘扩容
  15. matlab 差分方程的解(解答qq网友)
  16. 区块链市场——专为用户打造的一站式应用下载平台
  17. Linux 中的TAB键妙用
  18. C# 设置线程的默认CultureInfo
  19. 【CentOS】make cc Command not found,make: *** [adlist.o] Error 127”
  20. 地图慧一直显示服务器,瑞友慧连接服务端

热门文章

  1. 预告:大牛现身说法 TensorFlow在工程项目中的应用 | AI 研习社
  2. 利用java反射调用类的的私有方法--转
  3. 液态金属和Liquidmetal公司
  4. Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant)
  5. android Formatter 的使用
  6. JVM—方法区到底是怎么保存函数方法的?
  7. 性能瓶颈分析整体思路
  8. 数据库性能(一):数据库索引原理解析
  9. linux(CentOS)下安装mongodb
  10. Weighted-Entropy-based Quantization for Deep Neural Networks 论文笔记