如何写TreeView(JAVA)

java

如何写TreeView(JAVA)

<%@ page language="java" import="java.util.*"%>
<%@ page contentType="text/html;charset=gb2312"%>
   
<%@ page import="java.io.IOException" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.text.DateFormat" %>
<%@ page import="java.text.ParseException" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Hashtable" %>

<%@ page import="com.egosystems.balasbrid.main" %>
<%@ page import="com.egosystems.apputil.AppInfo" %>
<%@ page import="com.egosystems.apputil.Const" %>
<%@ page import="com.egosystems.apputil.Utility" %>
<%@ page import="com.egosystems.dbcore.DBGetResult" %>
<%@ page import="com.egosystems.dbcore.DataTable" %>
<%@ page import="com.egosystems.dbcore.DataTable.DataRow" %>
<%@ page import="com.egosystems.taglib.DataGrid" %>
<%@ page import="com.egosystems.taglib.Paginate" %>
<%@ page import="com.egosystems.dbcore.ParameterDirection" %>
<%@ page import="com.egosystems.dbcore.Parm_Struct" %>
<%@ page import="com.egosystems.taglib.TreeView" %>
<%@ page import="com.egosystems.webcore.BasePage" %>

<%@ taglib uri="/WEB-INF/EgoTag.tld" prefix="EGO"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%
    DBGetResult dbgr = new DBGetResult();
    dbgr.openConn();

    DataTable dataTable1 = null;
    DataTable dataTable2 = null;
    DataTable dataTable3 = null;

    TreeView TreeView1 = new TreeView();
    TreeView1.imagesBaseUrl = "TreeViewImages/";
    TreeView1.lineImagesFolderUrl = "TreeViewImages/lines/";
    TreeView1.nodeImageUrl = "file.gif";
    TreeView1.parentNodeImageUrl = "folder.gif";
    TreeView1.expandedParentNodeImageUrl = "folder_open.gif";

    TreeView1.Style = "backgroundFFFFFF;";
    String Sql1 = "select 编号,区域名称,guid from 支局区域";
    dataTable1 = dbgr.GetDataTable(Sql1);

    for (int i = 0; i < dataTable1.Rows.length; i++)
    {
        DataRow objdr = dataTable1.Rows;
       
        TreeView.Node treeNode = TreeView1.CreateNode();
        //treeNode.Text = objdr.Item("区域名称").ToString();
        treeNode.Text = "<a>"+objdr.Item("区域名称").ToString()+"</a>";
        treeNode.Url ="";
        treeNode.Target = "main";
        treeNode.Expanded = false;
        QYId = objdr.Item("编号").ToString();


        Sql2 = "select 支局编号,支局名,服务区域编号,guid from 支局信息 where ','+服务区域编号 like '%"+QYId+"%'";
        dataTable2 = dbgr.GetDataTable(Sql2);
       
        for (int j = 0; j < dataTable2.Rows.length; j++)
        {
            objdr = dataTable2.Rows[j];
            TreeView.Node treeNode2 = TreeView1.CreateNode();

            treeNode2.Text = "<a>"+objdr.Item("支局名").ToString()+"</a>";
           
            treeNode2.Target = "main";
            treeNode2.Expanded = false;

            Sql3 = "select 投递名称,编号,guid from 投递段 where charindex(编号,'"+objdr.Item("服务区域编号").ToString()+"',1)>0 and 区域编号='"+QYId+"'";
            dataTable3 = dbgr.GetDataTable(Sql3);
           
            for (int k = 0; k < dataTable3.Rows.length; k++)
            {
                objdr = dataTable3.Rows[k];
                TreeView.Node treeNode3 = TreeView1.CreateNode();
                treeNode3.Text = "<a>"+objdr.Item("投递名称").ToString()+"</a>";
               
                treeNode3.Target = "main";
                treeNode3.Expanded = false;
                treeNode2.Add(treeNode3);
            }
            treeNode.Add(treeNode2);
        }
    }
    request.setAttribute("treeViewObj", TreeView1);

   
%>

<script type="text/javascript">
    function setTreeSize()
    {
        var treeDiv = document.getElementById("tree");
        var h = parseInt(document.body.offsetHeight);
        var w = parseInt(document.body.offsetWidth);
        if(treeDiv != undefined)
        {
            if(h > 25)
            {
                treeDiv.style.height = h-325;
            }
            //treeDiv.style.width = w;
        }

    }
    window.onload = setTreeSize;
    window.onresize = setTreeSize;
</script>

<html>
    <head>
        <title><title>
        <script src="https://www.cnblogs.com/js/TreeViewExpand.js"></script>
    </head>
    <body>
        <div />
        </div>
    </body>
</html>

 

方正快速开发平台 FIX ES2007 www.founderfix.com

以上是 如何写TreeView(JAVA) 的全部内容, 来源链接: utcz.com/z/394316.html

回到顶部