123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <!DOCTYPE html>
- <HTML>
- <HEAD>
- <TITLE> ZTREE DEMO - radio select menu</TITLE>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <link rel="stylesheet" href="../../../css/demo.css" type="text/css">
- <link rel="stylesheet" href="../../../css/zTreeStyle/zTreeStyle.css" type="text/css">
- <script type="text/javascript" src="../../../js/jquery-1.4.4.min.js"></script>
- <script type="text/javascript" src="../../../js/jquery.ztree.core-3.5.js"></script>
- <script type="text/javascript" src="../../../js/jquery.ztree.excheck-3.5.js"></script>
- <!-- <script type="text/javascript" src="../../../js/jquery.ztree.exedit-3.5.js"></script>-->
- <SCRIPT type="text/javascript">
- <!--
- var setting = {
- check: {
- enable: true,
- chkStyle: "radio",
- radioType: "all"
- },
- view: {
- dblClickExpand: false
- },
- data: {
- simpleData: {
- enable: true
- }
- },
- callback: {
- onClick: onClick,
- onCheck: onCheck
- }
- };
- var zNodes =[
- {id:1, pId:0, name:"Beijing"},
- {id:2, pId:0, name:"Tianjin"},
- {id:3, pId:0, name:"Shanghai"},
- {id:6, pId:0, name:"Chongqing"},
- {id:4, pId:0, name:"Hebei Province", open:true},
- {id:41, pId:4, name:"Shijiazhuang"},
- {id:42, pId:4, name:"Baoding"},
- {id:43, pId:4, name:"Handan"},
- {id:44, pId:4, name:"Chengde"},
- {id:5, pId:0, name:"Guangdong Province", open:true},
- {id:51, pId:5, name:"Guangzhou"},
- {id:52, pId:5, name:"Shenzhen"},
- {id:53, pId:5, name:"Dongguan"},
- {id:54, pId:5, name:"Fushan"},
- {id:6, pId:0, name:"Fujian Province", open:true},
- {id:61, pId:6, name:"Fuzhou"},
- {id:62, pId:6, name:"Xiamen"},
- {id:63, pId:6, name:"Quanzhou"},
- {id:64, pId:6, name:"Sanming"}
- ];
- function onClick(e, treeId, treeNode) {
- var zTree = $.fn.zTree.getZTreeObj("treeDemo");
- zTree.checkNode(treeNode, !treeNode.checked, null, true);
- return false;
- }
- function onCheck(e, treeId, treeNode) {
- var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
- nodes = zTree.getCheckedNodes(true),
- v = "";
- for (var i=0, l=nodes.length; i<l; i++) {
- v += nodes[i].name + ",";
- }
- if (v.length > 0 ) v = v.substring(0, v.length-1);
- var cityObj = $("#citySel");
- cityObj.attr("value", v);
- }
- function showMenu() {
- var cityObj = $("#citySel");
- var cityOffset = $("#citySel").offset();
- $("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");
- $("body").bind("mousedown", onBodyDown);
- }
- function hideMenu() {
- $("#menuContent").fadeOut("fast");
- $("body").unbind("mousedown", onBodyDown);
- }
- function onBodyDown(event) {
- if (!(event.target.id == "menuBtn" || event.target.id == "citySel" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
- hideMenu();
- }
- }
- $(document).ready(function(){
- $.fn.zTree.init($("#treeDemo"), setting, zNodes);
- });
- //-->
- </SCRIPT>
- <style type="text/css">
- </style>
- </HEAD>
- <BODY>
- <h1>Drop-down Menu with radio</h1>
- <h6>[ File Path: super/select_menu_radio.html ]</h6>
- <div class="content_wrap">
- <div class="zTreeDemoBackground left">
- <ul class="list">
- <li class="title"> <span class="highlight_red">Check the radio to select or click the node</span></li>
- <li class="title"> Test: <input id="citySel" type="text" readonly value="" style="width:120px;" onclick="showMenu();" />
- <a id="menuBtn" href="#" onclick="showMenu(); return false;">select</a></li>
- </ul>
- </div>
- <div class="right">
- <ul class="info">
- <li class="title"><h2>Explanation of implementation method</h2>
- <ul class="list">
- <li>You can achieve single-selected drop-down menu with radio.</li>
- <li>This Demo is mainly used for compare with other drop-down menu.</li>
- </ul>
- </li>
- </ul>
- </div>
- </div>
- <div id="menuContent" class="menuContent" style="display:none; position: absolute;">
- <ul id="treeDemo" class="ztree" style="margin-top:0; width:180px; height: 300px;"></ul>
- </div>
- </BODY>
- </HTML>
|