2
回答
ztree在Ie下显示错位

求高手指点下,哪里配置错了。在ztree的select_menu_checkbox.html基础上改的。

var setting = {
check: {
enable: true,
chkboxType: {"Y":"", "N":""}
},
view: {
dblClickExpand: false
},
data: {
simpleData: {
enable: true
}
},
callback: {
beforeClick: beforeClick,
onCheck: onCheck
}
};


var zNodes;

function beforeClick(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 = $("#treeSel");
cityObj.attr("value", v);
}


function showMenu() {
var cityObj = $("#treeSel");
var cityOffset = $("#treeSel").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();
}
}


function treeInit(jsonData){
zNodes = jsonData;

}
  $(document).ready(function(){
getTreeData();
$.fn.zTree.init($("#treeDemo"), setting, zNodes);
});
  function getTreeData(){
$.ajax({
url:"getSelectTreeData.action",
type:"POST",
dataType:"json",
async:false,
success:function(data){
//调用通用方法 data为Json数据
treeInit(data);
}
});
}
JSP上面这样写的:

<tr>
<td class="align_right">监考教师:</td>
<td>
<input id="treeSel" name="treeSel" type="text" readonly value="" style="width:120px;" onclick="showMenu();" />
<span class="star">*</span>
</td>
<div id="menuContent" class="menuContent1" style="display:none; position: absolute;">
<ul id="treeDemo" class="ztree" style="margin-top:0; width:180px; height: 300px;"></ul>
</div>
</tr>

举报
顶部