<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>左右两侧固定列,中间内容可以横向拖动</title>
<link rel="stylesheet" href="./table.css">
<script src="./jquery.min.js"></script>
<script src="./table.js"></script>
<style>
</style>
</head>
<body>
<div class="fixed-table-box row-col-fixed">
<!-- 表头 start -->
<div class="fixed-table_header-wraper">
<table class="fixed-table_header" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th class="w-150" data-fixed="true">
<div class="table-cell">字段1</div>
</th>
<th class="w-120">
<div class="table-cell">字段2</div>
</th>
<th class="w-120">
<div class="table-cell">字段3</div>
</th>
<th class="w-120">
<div class="table-cell">字段4</div>
</th>
<th class="w-300">
<div class="table-cell">字段5</div>
</th>
<th class="w-120">
<div class="table-cell">字段6</div>
</th>
<th class="w-100" data-fixed="true" data-direction="right">
<div class="table-cell">字段7</div>
</th>
</tr>
</thead>
</table>
</div>
<!-- 表头 end -->
<!-- 表格内容 start -->
<div class="fixed-table_body-wraper">
<table class="fixed-table_body" cellspacing="0" cellpadding="0">
<tbody>
<!-- 中间表格内容 -->
</tbody>
</table>
</div>
<!-- 表格内容 end -->
<!-- 固定列 start -->
<div id="date" class="fixed-table_fixed fixed-table_fixed-left">
<div class="fixed-table_header-wraper">
<table class="fixed-table_header" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th class="w-150">
<div class="table-cell">字段1</div>
</th>
</tr>
</thead>
</table>
</div>
<div class="fixed-table_body-wraper">
<table class="fixed-table_body" cellspacing="0" cellpadding="0">
<tbody>
<!-- 第一个固定列 -->
</tbody>
</table>
</div>
</div>
<div id="operate" class="fixed-table_fixed fixed-table_fixed-right" style="right: 1px;">
<div id="operate1" class="fixed-table_header-wraper">
<table class="fixed-table_header" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th class="w-100">
<div class="table-cell">字段7</div>
</th>
</tr>
</thead>
</table>
</div>
<div class="fixed-table_body-wraper" style="margin-top: 41px;">
<table class="fixed-table_body" cellspacing="0" cellpadding="0">
<tbody>
<!-- 固定列的删除和操作 -->
</tbody>
</table>
</div>
</div>
<!-- 固定列 end -->
</div>
<div class="fixed-table-box_fixed-right-patch" style="width: 0px; height: 39px;"></div>
<div class="btns">
<button type="button" id="empty_data">清空数据</button>
<button type="button" id="add_data">添加数据</button>
<button type="button" id="del_row">删除行</button>
</div>
<script>
var random = 10000;
// var random = Math.random();
//初始化FixedTable
$(".fixed-table-box").fixedTable();
//清空表格
$("#empty_data").on("click", function () {
$(".fixed-table-box").emptyTable();
});
//添加数据
$("#add_data").on("click", function () {
$(".fixed-table-box").addRow(function () {
return getRowHtml();
});
});
//删除指定行
$("#del_row").on("click", function () {
$(".fixed-table-box").deleteRow($(".fixed-table-box").children('.fixed-table_fixed-left').children('.fixed-table_body-wraper').find('tr').eq(0));
});
//页面初始化给定一个20行的表格S
$(".fixed-table-box").addRow(function () {
var html = '';
for (let i = 0; i < 20; i++) {
html += getRowHtml();
}
return html;
});
function getRowHtml() {
random++;
// var random = Math.random();
// var random = Math.round(Math.random());
var html = '';
// for(var i = 0; i < 5; i ++){
html += '<tr>';
html += ' <td class="w-150"><div class="table-cell">' + random + '</div></td>';
html += ' <td class="w-120"><div class="table-cell">' + random + '</div></td>';
html += ' <td class="w-120"><div class="table-cell">' + random + '</div></td>';
html += ' <td class="w-120"><div class="table-cell">' + random + '</div></td>';
html += ' <td class="w-300"><div class="table-cell">' + random + '</div></td>';
html += ' <td class="w-120"><div class="table-cell">' + random + '</div></td>';
html += ' <td class="w-100">';
html += ' <div class="table-cell">';
html += ' <a href="###">查看</a>';
html += ' <a href="###">编辑</a>';
html += ' </div>';
html += ' </td>';
html += '</tr>';
// }
return html;
}
</script>
</body>
</html>
一颗小白羊
- 粉丝: 9
最新资源
- 基于物联网技术智能附着式脚手架智能控制保护系统的研究.docx
- 中小企业组建无线网络方案.docx
- 信用评软件设计方案方法的比较分析研究.doc
- 人力资源管理课程项目管理化设计.doc
- 互联网环境下中国电影市场在发展中存在的问题分析.docx
- 通信工程专业毕业论文.doc
- 认识计算机课件.ppt
- 智能交通系统中的计算机视觉技术应用研究.docx
- Web2.0-时代下的西藏旅游目的地形象建设初探.doc
- 浅析计算机存储器分层结构.docx
- 三级电子商务标准答案.docx
- 浅议中职计算机应用基础课程在非计算机专业教学中的改革与创新.docx
- sa算法及安全性分析.ppt
- 面向土木专业人才培养的《计算机程序设计》学习课程改革实践与探索.doc
- 新时期高校管理的信息化建设及国际化发展.docx
- 多媒体技术在中职计算机教学中的应用.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



