treeTable的使用(ajax异步获取数据,动态渲染treeTable)

本文介绍了如何使用ajax异步获取数据并动态渲染treeTable,包括展示效果、HTML文件的编写以及所需JS文件的配置。重点在于理解treetable的初始化和数据加载过程。
摘要由CSDN通过智能技术生成

一、展示效果(treetable基本样式https://www.cnblogs.com/shuihanxiao/p/10413454.html)

  

 

二、html文件(若一个页面又多个treetable,必须把所有table的html拼接好后,再调用treetable,treetable的js只初始化一次)

  

<!DOCTYPE html>
<html lang="en" style="height: 100%;">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="css/screen.css" media="screen"/>
<link rel="stylesheet" href="css/jquery.treetable.css"/>
<link rel="stylesheet" href="css/jquery.treetable.theme.default.css"/>
<style>

#parentId {
display: inline-block;
height: 100%;
width: 100%;
padding: 6px 12px;
border: 1px solid #ccc;
border-radius: 4px;
outline: none;
}

thead {
text-align: center;
}

th {
text-align: center;
}

td {
text-align: center;
}

table.treetable thead tr th {
background: #f2f2f2 !important;
border-top: 1px solid #ddd !important;
border-right: 1px solid #ddd !important;
padding: 8px 10px !important;
color: #555;
font-weight: 700;
text-align: center !important;
}

table.treetable tbody tr td {
padding: 8px 10px !important;
color: #555;
panel panel-default
text-align: center !important;
}

table.treetable tbody tr td:nth-of-type(1) {
text-align: left !important;
}

table.treetable tbody tr td a {
text-decoration: none !important;
color: #2fa4e7;
}

table.treetable tbody tr td a:hover {
color: #157ab5;
text-decoration: none;
}

table.treetable tr.selected {
background: #ffffff !important;
color: #000000 !important;
}

.table th, .table td {
border-left: 1px solid #ddd !important;
border-bottom: 1px solid #ddd !important;
border-right: 1px solid #ddd !important;
}

#example-advanced, #example-advanced1 {
top: 70px;
position: absolute;
}

.tabBox {
padding-left: 4px;
padding-top: 10px;
background: #eee;
overflow: hidden;
}

.tab-item {
float: left;
border-radius: 3px;
padding: 10px;
}

.tab-item-active {
background: #fff;
}

.interfaceInfoBase {
font-size: 13px;
color: #666;
}

.interfaceTitle {
font-size: 14px;
color: #333;
font-weight: 700;
}

.interfaceTitle > div, .interfaceTitle > div {
line-height: 20px;
}
</style>
</head>
<body style='overflow:scroll;overflow-x:hidden;height: 100%;margin: 0'>
<script type="text/javascript">
// $(document).ready(function() {
// $("#treeTable").treeTable({expandLevel : 2});
// });
</script>
<div class="container bs-docs-container" style="width:100%;height: 100%;">
<div class="row" style="height: 100%;">
<div id="interfaceId" style="display: none">
$!{jropenInterfaceInfo.id}
</div>

<form role="form" class="form-horizontal" action="/documentCategory/list" method="post" id="formSubmit"
style="height: 100%;width: 100%">
<div class="col-md-10" style="width:100%;height: 100%">
<div class="panel panel-default" style="height: 100%">
<div class="panel-body">
<!-- 接口基本信息-->
<div>
<div style="interfaceInfoBase">
<div><span style="font-size: 16px;font-weight: 700">参数参数参数参数参数$!{jropenInterfaceInfo.jropenInterfaceInfo.interfaceName}</span><span
style="font-size: 12px;color: #666;margin-left: 15px">1.0.1$!{jropenInterfaceInfo.jropenInterfaceInfo.interfaceName}</span>
</div>

</div>
<div id="fadeBox">
<div>
<span class="interfaceTitle">外部请求接口地址</span>
<span>$!{jropenInterfaceInfo.jropenInterfaceInfo.interfaceName}</span>
</div>
</div>
</div>
<!-- 编辑折叠按钮-->
<div>
<div id="legend" class="mb20 mt15">
<legend class="le" style="overflow: hidden">
<button id="adDocumentCategory" type="button" class="btn btn-primary"
style="float:left"
οnclick="doFadeToggel()">折叠
</button>
</legend>
</div>
</div>
<!-- table切换头-->
<div style="position: relative">
<div class="tabBox">
<div class="tab-item tab-item-active tab-item1">请求参数</div>
<div class="tab-item tab-item2">响应参数</div>
</div>
<table id="example-advanced"
class="example-advanced table table-striped table-bordered table-condensed tree_table">
<thead>
<tr>
<th><span>参数</span></th>
<th><span>参数名称</span></th>
<th><span>数据类型</span></th>
<th><span>参数类型</span></th>
<th><span>必填</span></th>
<th><span>业务字段编码</span></th>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值