dhtmlXtree复选框的选中值怎样取到?java springMVC项目

小黑猪儿 发布于 2013/09/21 22:52
阅读 791
收藏 0

我做了一个dhtmlXtree带复选框,现在需求想把这个树页面作为一个选择页面,当我在复选框中勾选好几个,然后点击页面的确定按钮,我要把选中的内容和id都拿到,返回到父窗口进行显示。可是内容和id怎样拿呢?本人新手,求高人指点。我写的树的页面如下:

<%@ page language="java" contentType="text/html;  charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/share/taglib.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>分类菜单树</title>
    <link href="${ctx}/static/css/style.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/static/css/table.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/static/dhtmlxtree/dhtmlxtree.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="${ctx}/static/dhtmlxtree/dhtmlxcommon.js"></script>
    <script type="text/javascript" src="${ctx}/static/dhtmlxtree/dhtmlxtree.js"></script>
</head>
<body>
<table>
    <tr>
        <td></td>
    </tr>
    <tr>
        <td>
            <div id="treeboxbox_tree"></div>
        </td>
    </tr>
<!--     <tr> -->
<%--         <td><input type="button" value="选中节点" onclick="window.location.href='${ctx}/knowledge/category/selectedList?list=tree.getAllChecked()';" /></td> --%>
<!--     </tr> -->
</table>    
<script>
    tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
    tree.setImagePath("${ctx}/static/dhtmlxtree/imgs/csh_books/");
    tree.enableCheckBoxes(1);
    tree.setCheck(tree.getSelectedItemId(),true);
    //页面首次载入执行,主要是取得根节点
    tree.loadXML("${ctx}/knowledge/category/makeTree?id=0");
    //每次点击机构执行,会将机构的id加入到该URL后面进行传递,如:category/makeTree?id=选中节点的id
    tree.setXMLAutoLoading("${ctx}/knowledge/category/makeTree");
    tree.setOnClickHandler(function() {
        window.parent.cateWorkareaFrame.location="${ctx}/knowledge/category/detail?id=" + tree.getSelectedItemId();
    });
    //得到所有选中节点
    //var list=tree.getAllChecked();

</script>
</body>
</html>

加载中
返回顶部
顶部