jQuery樹形結構選擇器代碼



113 450 151



特效描述:jQuery 樹形選擇器代碼,jQuery樹形結構選擇器代碼

代碼結構

1. 引入CSS

<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/tree.css">

2. 引入JS

<script src="js/jquery-1.10.2.js"></script>
<script src="js/jquery-ui-1.11.0.js"></script>
<script src="js/bootstrap-3.3.4.js"></script>
<script src="js/tree.js"></script>

3. HTML代碼

<div class="row">
	<!-- 默認樹結構表格 -->
	<div id="default_tree" class="col-sm-4"><h3>原始樹結構</h3></div>
	<!-- 保存的數據 -->
	<div id="tree_data" class="col-sm-4"><h3>選中的數據</h3><div></div></div>
	<div id="select_tree" class="col-sm-4"><h3>選中的樹結構</h3><div></div></div>
</div>
<button id="setBtn" class="btn btn-primary">設置</button>
<div class="modal toggle" id="myModal" data-backdrop="static">
	<div id="modalDialog" class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button class="btn btn-default modal-btn" id="closeBtn" aria-hidden="true" title="關閉"><i class="fa fa-close"></i></button>
				<button class="btn btn-default modal-btn" id="saveBtn" title="保存"><i class="fa fa-save"></i></button>
				<div class="modal-title">表格-列選擇</div>
			</div>
			<div class="modal-body">
				<!-- 默認樹表格 -->
				<div id="tree_table"></div>
			</div>
			<div class="modal-footer">
				<!-- 選中的數表格 -->
				<h2 align="left">預覽</h2>
				<div id="select_tree_table"></div>
			</div>
		</div>
	</div>
</div>
<script>
$(document).ready(function(){
	var data2 = [
		{title: "編碼", field: "code",candidate: false},
		{title: "基本信息", open: true, children:[
			{title: "名稱", field: "name", candidate: true},
			{title: "年齡", field: "age", candidate: true},
			{title: "性別", field: "sex", candidate: true}
		]}
	];
	var data = [
		{title: "編碼", field: "code",candidate: false},
		{title: "基本信息", open: true, children:[
			{title: "名稱", field: "name", candidate: true},
			{title: "年齡", field: "age", candidate: true},
			{title: "性別", field: "sex", candidate: true},
			{title: '教育相關1', open: true, children:[
				{title: "最高學歷1", field: "education", candidate: true},
				{title: "畢業學校1", field: "college", candidate: true},
				{title: "所學技術1", open:true, children: [
					{title: "Java編程1", field: 'java', candidate: true},
					{title: "Oracle數據操作1", field: 'oracle', candidate: true},
					{title: "網頁設計1", field: 'html', candidate: true}
				]}
			]},
			{title: '教育相關2', open: true, children:[
				{title: "最高學歷2", field: "education", candidate: true},
				{title: "畢業學校2", field: "college", candidate: true},
				{title: "所學技術2", open:true, children: [
					{title: "Java編程2", field: 'java', candidate: true},
					{title: "Oracle數據操作2", field: 'oracle', candidate: true},
					{title: "網頁設計2", field: 'html', candidate: true}
				]}
			]}
		]},
		{title: '工作信息', open: true, children:[
			{title: "職位", field: "office", candidate: true},
			{title: "職稱", field: "call", candidate: true},
			{title: "所在樓層", field: "place", candidate: true}
		]}
	];
	$('#default_tree').append(loadTree(data));
	nodeClick($('#default_tree'));
	// 是否已保存數據
	var isSave = false;
	$('#setBtn').click(function(){
		$('#tree_table').empty();
		$('#tree_table').append(loadTreeTable(data));
		tableClick();
		$('#select_tree_table').empty();
		// 加載已選中的數據
		if(selectData != undefined && selectData.length > 0 && isSave){
			$('#select_tree_table').append(loadTreeTable(selectData));
		} else{
			$('#select_tree_table').append(loadTreeTable([{title:'編碼', field:'code', candidate:false}]));
		}
		$('#myModal').modal('show');
	})
	// 保存數據
	$('#saveBtn').click(function(){
		$('#select_tree>div').empty();
		// 獲取選中的葉子 field
		$('#tree_data>div').empty();
		if(selectData != undefined && selectData.length > 1){
			$('#select_tree>div').append(loadTree(selectData));
			$('#tree_data>div').append("[" + result(selectData) + "]");
			nodeClick($('#select_tree>div'));
		}
		isSave = true;
		$('#myModal').modal('hide');
	})
	$('#closeBtn').click(function(){
		$('#myModal').modal('hide');
	})
})
</script>



用戶評論
大牛,別默默的看了,快登錄幫我點評一下吧!:)      登錄 | 注冊


熱門標簽: flash導航菜單 flash導航條 flash導航 flash菜單 flash下拉菜單 flash下拉導航菜單 h5動畫導航 h5動畫菜單 html5動畫導航 html5動畫菜單 收縮菜單 收縮導航 右鍵菜單 導航切換 菜單切換 浮動菜單 浮動導航 滑動導航菜單 滑動導航 滑動菜單 滾動導航菜單 滾動菜單 滾動導航 彈出層拖動 浮動 懸浮 懸浮層 懸浮框 浮動層 浮動框 浮動插件 懸浮插件 窗口 彈出 彈窗 彈出層 提示框 對話框 遮罩 遮罩層 彈窗插件 收縮展開 展開收縮 收縮 展開 浮動提示框 導航菜單 導航條 菜單欄 導航欄 分類導航 響應式導航條 響應式導航 浮動菜單 浮動導航 收縮菜單 收縮導航 提示框/彈出層 樹形菜單 樹形導航
?
×
×

注冊

官方QQ群

掃描上面二維碼加微信群

官方QQ群

jQuery/js討論群
群號:642649996
Css3+Html5討論群
群號:322131262

加群請備注:從官網了解到

湖北30选5开奖结果走势图表