• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com专业计算机教程网站
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure
您的位置:首页 > 网页设计 >bootstrap > bootstrap table复杂操作代码

bootstrap table复杂操作代码

作者:minsgo 字体:[增加 减小] 来源:互联网 时间:2017-05-30

本文主要包含bootstrap table,bootstrap table样式,bootstraptable api,bootstrap table插件,bootstrap table 分页等相关知识,minsgo 希望在学习及工作中可以帮助到您

本文实例为大家分享了bootstrap table复杂操作,如何生成外层表格,如何填充表格内容,供大家参考,具体内容如下

1、先生成外层表格:

$('#tableActivity').bootstrapTable('destroy').bootstrapTable({
  url:'',
  detailView:true,
  detailFormatter:"detailFormatter",//点击展开预先执行事件
  cache: false,
  height: 550,
  showExport: true,
  exportDataType: "all", 
  pagination: true,
  pageSize: 10,
  pageList: [10, 25, 50, 100],
  search: true,
  searchAlign:'left',
  showRefresh: true,
  showToggle: true,
  showColumns: true,
  toolbarAlign: 'right',
  toolbar:"#toolbar",
  buttonsAlign:'left',
  clickToSelect: true,
  idField:'',
  columns: [
   [
    {
    title:'编号',
    field: 'index',
    rowspan: 2,
    align: 'center',
    valign: 'middle'
    }, {
    title: '姓名',
    field: 'userName',
    rowspan: 2,
    align: 'center',
    valign: 'middle',
    sortable: true

    }, {
    title: '讲义',
    colspan: 3,
    align: 'center'
    }, {
    title: '视频',
    colspan: 3,
    align: 'center'
    }, {
    title: '总完成情况',
    colspan: 3,
    align: 'center'
    }
   ],
   [
    {
    field: 'handoutCount',
    title: '讲义总数',
    sortable: true,
    align: 'center'
    }, {
    field: 'handoutComCount',
    title: '完成数',
    sortable: true,
    align: 'center'

    }, {
    field: 'handoutCountDegree',
    title: '完成率',
    sortable: true,
    align: 'center'


    }, {
    field: 'videoCount',
    title: '视频总数',
    sortable: true,
    align: 'center'


    }, {
    field: 'videoComCount',
    title: '完成数',
    sortable: true,
    align: 'center'


    }, {
    field: 'videoCountDegree',
    title: '完成率',
    sortable: true,
    align: 'center'


    }, {
    field: 'allCount',
    title: '总数',
    sortable: true,
    align: 'center'


    }, {
    field: 'allComCount',
    title: '总完成数',
    sortable: true,
    align: 'center'


    }, {
    field: 'allDegree',
    title: '总完成率',
    sortable: true,
    align: 'center'


    }
   ]

   ]

 });
</div>

2、生成展开之后的表格内容:

function detailFormatter(index, row) {
  handoutColums=[];
  handoutData=[];
  videoColums=[];
  videoData=[];
  var html = [];
  html.push('<div class="row">');
  html.push('<div class="col-md-6">');
  html.push('<table id="tableHandout'+index+'"></table>');
  html.push('</div>');
  html.push('<div class="col-md-6">');
  html.push('<table id="tableVideo'+index+'"></table>');
  html.push('</div>');
  html.push('</div>');
  handoutColums.push({
   field: 'handoutIndex',title: '编号', sortable: true ,width: 150
  },{
   field: 'handoutName',title: '讲义名称', sortable: true ,width: 150
  },{
   field: 'degree',title: '完成度', sortable: true ,width: 150
  });
  videoColums.push({
   field: 'videoIndex',title: '编号', sortable: true ,width: 150
  },{
   field: 'videoName',title: '视频名称', sortable: true ,width: 150
  },{
   field: 'degree',title: '完成度', sortable: true ,width: 150
  });
  $.each(row, function (key, value) {
   if(key=="handout"){
   $.each(value,function(index,handout){
   var row = {};
   row['handoutIndex'] = index+1;
   row['handoutName']=handout.handoutName;
   row['degree']=handout.degree;
   handoutData.push(row);

   });
   }
   if(key=="video"){
   $.each(value,function(index,video){
   var row = {};
   row['videoIndex']=index+1;
   row['videoName']=video.videoName;
   row['degree']=video.degree;
   videoData.push(row);
   });
   }
  });

  return html.join('');
  }
</div>

3、填充表格内容:

$('#tableActivity').on('expand-row.bs.table', function (e, index, row, $detail) {
  initHandoutTable(handoutColums,handoutData,index);
  initVideoTable(videoColums,videoData,index);
  }); 

  function initHandoutTable(colums,data,index){


  $('#tableHandout'+index).bootstrapTable('destroy').bootstrapTable({
   cache: false,
   height: 200,
   clickToSelect: true,
   idField:'',
   columns:colums,
   data:data
  });

  }

  function initVideoTable(colums,data,index){


  $('#tableVideo'+index).bootstrapTable('destroy').bootstrapTable({
   cache: false,
   height: 200,
   clickToSelect: true,
   idField:'',
   columns:colums,
   data:data
  });

  }

</div>

如果大家还想深入学习,可以点击这里进行学习,再为大家附两个精彩的专题:Bootstrap学习教程 Bootstrap实战教程 Bootstrap插件使用教程

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

</div>

您可能想查找下面的文章:

  • Bootstrap布局组件
  • 关于BootstrapTable的使用
  • Bootstrap 插件概览
  • Bootstrap table分页问题汇总
  • BootStrap中的table实现数据填充与分页应用小结
  • 解决JS组件bootstrap table分页实现过程中遇到的问题
  • bootstrap table 服务器端分页例子分享
  • JS组件Bootstrap导航条使用方法详解
  • JS组件Bootstrap实现下拉菜单效果代码
  • JS组件Bootstrap实现弹出框效果代码

相关文章

  • 2017-05-30Bootstrap CSS组件之下拉菜单(dropdown)
  • 2017-05-30Bootstrap框架下下拉框select搜索功能
  • 2017-05-30Bootstrap3多级下拉菜单
  • 2017-05-22Bootstrap 下拉菜单(Dropdown)插件
  • 2017-05-30JS组件Bootstrap Table使用实例分享
  • 2017-05-30基于BootstrapValidator的Form表单验证(24)
  • 2017-05-30Bootstrap3学习笔记(二)之排版
  • 2017-05-22Bootstrap 警告框
  • 2017-05-30基于BootStrap的图片轮播效果展示实例代码
  • 2017-05-30BootStrap的弹出框(Popover)支持鼠标移到弹出层上弹窗层不隐藏的原因及解决办法

文章分类

  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure

最近更新的内容

    • JS组件Bootstrap Table使用方法详解
    • 学习Bootstrap组件之下拉菜单
    • Bootstrap入门书籍之(四)菜单、按钮及导航
    • bootstrap table 服务器端分页例子分享
    • Bootstrap table使用方法详细介绍
    • Bootstrap~多级导航(级联导航)的实现效果【附代码】
    • bootstrap学习使用(导航条、下拉菜单、轮播、栅格布局等)
    • Bootstrap布局方式详解
    • Bootstrap导航条可点击和鼠标悬停显示下拉菜单
    • 基于BootStrap Metronic开发框架经验小结【二】列表分页处理和插件JSTree的使用

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有