bootstrap的表格样式,有类似EasyUI的表格,也有卡片式表格,放到移动端显示,各有千秋。但是BootStrap自带的表格是没有操作列的,网上的资源不少,但是都是比较单一、零碎,JS、CSS也经常给的不全,自己经过大概一个月左右的时间,把表格封装了一下,希望能分享给大家。
表格封装了3个版本,接下来给大家展示一下样式和代码。
1. 样式
表格布局:
添加:添加一行新的空白代码
修改:选中可修改的列,点击需要修改的单元格,即可变成可编辑的状态。
2.代码
1. 样式
布局样式:
添加/修改:
2. 代码
[html] view plain copy
- @using ITOO.FreshNewReport.ViewModel
- @{
- Layout = null;
- }
- <html>
- <head>
- <title>数据表格编辑_大气漂亮的Bootstrap后台管理系统模板Se7en - JS代码网
- title>
- <link href="../../BootStrap/se7ven/../../BootStrap/se7ven/stylesheets/bootstrap.min.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/font-awesome.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/se7en-font.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/isotope.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/jquery.fancybox.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/fullcalendar.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/wizard.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/select2.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/morris.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/datatables.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/datepicker.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/timepicker.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/colorpicker.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/bootstrap-switch.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/daterange-picker.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/typeahead.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/summernote.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/pygments.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/style.css" media="all" rel="stylesheet" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/color/green.css" media="all" rel="alternate stylesheet" title="green-theme" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/color/orange.css" media="all" rel="alternate stylesheet" title="orange-theme" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/color/magenta.css" media="all" rel="alternate stylesheet" title="magenta-theme" type="text/css" />
- <link href="../../BootStrap/se7ven/stylesheets/color/gray.css" media="all" rel="alternate stylesheet" title="gray-theme" type="text/css" />
- <script src="../../BootStrap/se7ven/javascripts/jquery.min.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/jquery-ui.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/bootstrap.min.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/raphael.min.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/selectivizr-min.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/jquery.mousewheel.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/jquery.vmap.min.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/jquery.vmap.sampledata.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/jquery.vmap.world.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/jquery.bootstrap.wizard.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/fullcalendar.min.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/gcal.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/jquery.dataTables.min.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/datatable-editable.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/jquery.easy-pie-chart.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/excanvas.min.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/jquery.isotope.min.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/isotope_extras.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/modernizr.custom.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/jquery.fancybox.pack.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/select2.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/styleswitcher.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/wysiwyg.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/summernote.min.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/jquery.inputmask.min.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/jquery.validate.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/bootstrap-fileupload.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/bootstrap-datepicker.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/bootstrap-timepicker.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/bootstrap-colorpicker.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/bootstrap-switch.min.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/typeahead.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/daterange-picker.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/date.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/morris.min.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/skycons.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/fitvids.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/jquery.sparkline.min.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/main.js" type="text/javascript">script>
- <script src="../../BootStrap/se7ven/javascripts/respond.js" type="text/javascript">script>
- <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
- head>
- <body>
- <div class="modal-shiftfix">
- <div class="container-fluid main-content">
- <div class="page-title">
- <h1>Editable DataTables
- h1>
- div>
- <div class="row">
- <div class="col-lg-12">
- <div class="widget-container fluid-height clearfix">
- <div class="heading">
- <i class="icon-table">i>DataTable with Sorting<a class="btn btn-sm btn-primary-outline pull-right" href="#" id="add-row"><i class="icon-plus">i>Add rowa>
- div>
- <div class="widget-content padded clearfix">
- <table class="table table-bordered table-striped" id="datatable-editable">
- <thead>
- @*<th class="check-header hidden-xs">
- <input id="checkAll" name="checkAll" type="checkbox">*@
- <th>姓名th>
- <th>称谓 th>
- <th>年龄 th>
- <th>政治面貌th>
- <th>电话号码 th>
- <th>工作单位th>
- <th class="hidden-xs">家庭住址th>
- <th width="60">th>
- <th width="75">th>
- thead>
- <tbody>
- @foreach (FamilyInfoViewModel enStuFam in ViewData["DataList"] as List<FamilyInfoViewModel>)
- {
- <tr>
- @*<td>
- <input name="checkbox" type="checkbox" id="1">
- td>*@
- <td>@enStuFam.Name td>
- <td>@enStuFam.RelationShiptd>
- <td>@enStuFam.Agetd>
- <td>@enStuFam.PoliticalStatustd>
- <td>@enStuFam.TelNum td>
- <td>@enStuFam.WorkUnittd>
- <td>@enStuFam.Address td>
- <td>
- <a class="edit-row" href="#">Edita>
- td>
- <td>
- <a class="delete-row" href="#">Deletea>
- td>
- tr>
- }
- tbody>
- table>
- div>
- div>
- div>
- div>
- div>
- div>
- body>
- html>
1.样式
卡片式表格:
添加/修改 弹出一个新页面:
2.代码
View代码: