Bootstrap table: http://bootstrap-table.wenzhixin.net.cn/zh-cn/getting-started/

1. 控制器代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc; namespace AspDotNetMVCBootstrapTable.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
} public JsonResult GetData()
{
var products = new[] {
new Product { ID = "", Name = "Item 1", Price = "$1" },
new Product { ID = "", Name = "Item 2", Price = "$1" },
new Product { ID = "", Name = "Item 3", Price = "$1" },
new Product { ID = "", Name = "Item 4", Price = "$4" },
new Product { ID = "", Name = "Item 5", Price = "$5" },
new Product { ID = "", Name = "Item 6", Price = "$6" },
new Product { ID = "", Name = "Item 7", Price = "$7" },
new Product { ID = "", Name = "Item 8", Price = "$8" },
new Product { ID = "", Name = "Item 9", Price = "$9" },
new Product { ID = "", Name = "Item 10", Price = "$10" },
new Product { ID = "", Name = "Item 11", Price = "$11" },
new Product { ID = "", Name = "Item 12", Price = "$12" },
new Product { ID = "", Name = "Item 13", Price = "$13" },
new Product { ID = "", Name = "Item 14", Price = "$14" },
new Product { ID = "", Name = "Item 15", Price = "$15" },
new Product { ID = "", Name = "Item 16", Price = "$16" },
new Product { ID = "", Name = "Item 17", Price = "$17" },
new Product { ID = "", Name = "Item 18", Price = "$18" },
new Product { ID = "", Name = "Item 19", Price = "$19" },
new Product { ID = "", Name = "Item 20", Price = "$20" },
new Product { ID = "", Name = "Item 21", Price = "$21" },
new Product { ID = "", Name = "Item 22", Price = "$22" },
new Product { ID = "", Name = "Item 23", Price = "$23" },
new Product { ID = "", Name = "Item 24", Price = "$24" },
new Product { ID = "", Name = "Item 25", Price = "$25" },
new Product { ID = "", Name = "Item 26", Price = "$26" },
new Product { ID = "", Name = "Item 27", Price = "$27" },
new Product { ID = "", Name = "Item 28", Price = "$28" },
new Product { ID = "", Name = "Item 29", Price = "$29" },
new Product { ID = "", Name = "Item 30", Price = "$30" },
}; return Json(products.ToList(), JsonRequestBehavior.AllowGet); } public ActionResult About()
{
ViewBag.Message = "Your application description page."; return View();
} public ActionResult Contact()
{
ViewBag.Message = "Your contact page."; return View();
} private class Product
{
public string ID { get; set; }
public string Name { get; set; }
public string Price { get; set; }
} }
}

2. 视图代码:

@{
ViewBag.Title = "Home Page";
}
@section css {
<link href="~/Scripts/Bootstrap-Table-1.5.0/bootstrap-table.min.css" rel="stylesheet" />
<style type="text/css"> </style>
}
<div class="row">
<div class="col-md-12">
<h2>ASP.NET MVC and Bootstrap Table Integration</h2>
<table id="table-javascript"></table>
</div>
</div>
@section Scripts {
<script src="~/Scripts/Bootstrap-Table-1.5.0/bootstrap-table.min.js"></script>
<script src="~/Scripts/Bootstrap-Table-1.5.0/locale/bootstrap-table-en-US.min.js"></script>
<script type="text/javascript">
$(function () {
$('#table-javascript').bootstrapTable({
method: 'get',
url: '/Home/GetData',
cache: false,
height: ,
striped: true,
pagination: true,
pageSize: ,
pageList: [, , , , ],
search: true,
showColumns: true,
showRefresh: true,
minimumCountColumns: ,
clickToSelect: true,
columns: [{
field: 'state',
checkbox: true
}, {
field: 'ID',
title: 'Item ID',
align: 'right',
valign: 'bottom',
sortable: true
}, {
field: 'Name',
title: 'Item Name',
align: 'center',
valign: 'middle',
sortable: true
}, {
field: 'Price',
title: 'Item Price',
align: 'left',
valign: 'top',
sortable: true
}, {
field: 'operate',
title: 'Item Operate',
align: 'center',
valign: 'middle',
clickToSelect: false,
formatter: operateFormatter,
events: operateEvents
}]
}); }); function operateFormatter(value, row, index) {
return [
'<a class="like" href="javascript:void(0)" title="Like">',
'<i class="glyphicon glyphicon-heart"></i>',
'</a>',
' <a class="edit ml10" href="javascript:void(0)" title="Edit">',
'<i class="glyphicon glyphicon-edit"></i>',
'</a>',
' <a class="remove ml10" href="javascript:void(0)" title="Remove">',
'<i class="glyphicon glyphicon-remove"></i>',
'</a>'
].join('');
} window.operateEvents = {
'click .like': function (e, value, row, index) {
alert('You click like icon, row: ' + JSON.stringify(row));
console.log(value, row, index);
},
'click .edit': function (e, value, row, index) {
alert('You click edit icon, row: ' + JSON.stringify(row));
console.log(value, row, index);
},
'click .remove': function (e, value, row, index) {
alert('You click remove icon, row: ' + JSON.stringify(row));
console.log(value, row, index);
}
}; </script>
}

项目代码查看地址: http://mvcbootstraptable.codeplex.com/

另: MVC中对Bootstrap的封装: http://mvc4bootstaphelper.codeplex.com/ (感觉一般用不到)

在ASP.NET MVC中使用 Bootstrap table插件的更多相关文章

  1. bootstrap table 插件多语言切换

    在bootstrap中的bootstrap table 插件在多语言切换的审核,只需要如下操作 引入bootstrap-table-locale-all.js文件 $('#Grid').bootstr ...

  2. ASP.NET Identity系列02,在ASP.NET MVC中增删改查用户

    本篇体验在ASP.NET MVC中使用ASP.NET Identity增删改查用户. 源码在这里:https://github.com/darrenji/UseIdentityCRUDUserInMV ...

  3. 2.ASP.NET MVC 中使用Crystal Report水晶报表

    上一篇,介绍了怎么导出Excel文件,这篇文章介绍在ASP.NET MVC中使用水晶报表. 项目源码下载:https://github.com/caofangsheng93/CrystalReport ...

  4. 如何在 ASP.NET MVC 中集成 AngularJS(2)

    在如何在 ASP.NET MVC 中集成 AngularJS(1)中,我们介绍了 ASP.NET MVC 捆绑和压缩.应用程序版本自动刷新和工程构建等内容. 下面介绍如何在 ASP.NET MVC 中 ...

  5. 《Entity Framework 6 Recipes》中文翻译系列 (20) -----第四章 ASP.NET MVC中使用实体框架之在MVC中构建一个CRUD示例

    翻译的初衷以及为什么选择<Entity Framework 6 Recipes>来学习,请看本系列开篇 第四章  ASP.NET MVC中使用实体框架 ASP.NET是一个免费的Web框架 ...

  6. 在 ASP.NET MVC 中充分利用 WebGrid (microsoft 官方示例)

    在 ASP.NET MVC 中充分利用 WebGrid https://msdn.microsoft.com/zh-cn/magazine/hh288075.aspx Stuart Leeks 下载代 ...

  7. 如何在 ASP.NET MVC 中集成 AngularJS(1)

    介绍 当涉及到计算机软件的开发时,我想运用所有的最新技术.例如,前端使用最新的 JavaScript 技术,服务器端使用最新的基于 REST 的 Web API 服务.另外,还有最新的数据库技术.最新 ...

  8. 在ASP.NET MVC中实现基于URL的权限控制

    本示例演示了在ASP.NET MVC中进行基于URL的权限控制,由于是基于URL进行控制的,所以只能精确到页.这种权限控制的优点是可以在已有的项目上改动极少的代码来增加权限控制功能,和项目本身的耦合度 ...

  9. NPOI以及在ASP.NET MVC中的使用

    NPOI以及在ASP.NET MVC中的使用 1.前言 相信大家在工作中经常要遇到一些导入导出Execl操作.学习贵在分享,分享使人快乐,园子里的前辈已经有很多好的文章,鄙人也是能力有限,在这里把这些 ...

随机推荐

  1. HDU 5521 Meeting

    2015 ACM / ICPC 沈阳站现场赛 M题 最短路 设置N+M个节点,前N个节点是Block,后M个节点是Set,每一组Set中的点向该Set连边,从1和n开始分别求最短路.注意爆int. # ...

  2. PAT1012

    To evaluate the performance of our first year CS majored students, 为了计算第一年计算机科学学生的表现 we consider the ...

  3. mknod用法以及主次设备号【转】

    转自:http://www.cnblogs.com/hnrainll/archive/2011/06/10/2077583.html mknod 用途 创建特殊文件. mknod Name { b | ...

  4. office加载项部署清单签名的证书或其位置不受信任

    异常信息: System.Security.SecurityException: 此应用程序中的自定义功能将不起作用,原因是用于为 BIMT写作指导 的部署清单签名的证书或其位置不受信任.请向管理员寻 ...

  5. BNU OJ 51003 BQG's Confusing Sequence

    二进制++高精度取模 #include<cstdio> #include<cstring> #include<algorithm> using namespace ...

  6. Unity3d/2d手机游戏开发第二版 (金玺曾) 随书资源

    http://pan.baidu.com/s/1c0xpn4s Unity3d2d手机游戏开发配书资源文件.rar 1.36G 书上的链接坏掉了,我在论坛上面买了一份,放这分享给买了书找不到资源的同学 ...

  7. LPC1788的spi使用

    #ifndef __SPI_H_ #define __SPI_H_ #include "common.h" #include "delay.h" // cs p ...

  8. IOS NSURLRequest 设置 Header

    https://my.oschina.net/wolx/blog/406092 工程中的请求,需要设置Header,请求令牌才访问,NSURLRequest 请求没有直接设置header 的方法,需要 ...

  9. java8 stream ,filter 等功能代替for循环

    直接上代码,比较实在. 对象A public Class A{ private Long id; private String userName; ..... ....省略get和set方法 } 在L ...

  10. IOS开发-UI学习-UIPageControl(页码控制器)的使用

    UIPageControl即页码控制器,是在翻动图片阅览时下面显示的几个小点,属性设置如下: UIPageControl *pagecontrol = [[UIPageControl alloc]in ...