ITPub博客

首页 > Linux操作系统 > Linux操作系统 > TreePanel

TreePanel

原创 Linux操作系统 作者:hireats 时间:2008-03-05 08:08:13 0 删除 编辑

文档一(recorder.html

文档二(recorder.js):

文档三(get-nodes.ashx

文档四(get-nodes.txt:返回根节点下的一级树

文档(get-subnodes.txt:返回节点下的一级树

 

文档一(recorder.html):

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Reorder TreePaneltitle>

<link rel="stylesheet" type="text/css" href="../ext-2.0/resources/css/ext-all.css" />

 

    <link href="../ext-2.0/resources/css/xtheme-gray.css" rel="stylesheet" type="text/css" />

     <script type="text/javascript" src="../ext-2.0/adapter/ext/ext-base.js">script>

     <!-- ENDLIBS -->

 

    <script type="text/javascript" src="../ext-2.0/ext-all.js">script>

<script type="text/javascript" src="reorder.js">script>

 

<!-- Common Styles for the examples -->

head>

<body>

 

<div id="tree-div" style="overflow:auto; height:300px;width:250px;border:1px solid #c3daf9;">div>

 

body>

html>

 

文档二(recorder.js):

/*

 * Ext JS Library 2.0.2

 * Copyright(c) 2006-2008, Ext JS, LLC.

 * licensing@extjs.com

 *

 * http://extjs.com/license

 */

Ext.SSL_SECURE_URL="/ext-2.0/resources/images/default/s.gif";
Ext.BLANK_IMAGE_URL="/ext-2.0/resources/images/default/s.gif";

Ext.onReady(function(){

    // shorthand

    var Tree = Ext.tree;

   

    var tree = new Tree.TreePanel({

        el:'tree-div',

        useArrows:true,

        autoScroll:true,

        animate:true,

        enableDD:true,

        containerScroll: true,

        loader: new Tree.TreeLoader({

            dataUrl:'get-nodes.ashx'

        })

    });0

 

    // set the root node

    var root = new Tree.AsyncTreeNode({

        text: '系统管理员',

        draggable:false,

        id:'source'

    });

    tree.setRootNode(root);

 

    // render the tree

    tree.render();

    root.expand();

});

 

文档三(get-nodes.ashx):

<%@ WebHandler Language="C#" Class="Login" %>

 

using System;

using System.Web;

 

public class Login : IHttpHandler

{

 

    public void ProcessRequest(HttpContext context)

    {

        context.Response.ContentType = "text/plain";

        /*

         * treePanel 中具有子节点的node被单击时会向dataUrl发送请求,格式如下:

         * Method:POST

         * POSTDATA:node=source(返回根节点下的一级树)

         *          node=nodeid(返回nodeid节点下的一级树)

         */

        string postNode = context.Request.Form["node"];

        if (!string.IsNullOrEmpty(postNode))

            if (postNode == "source")

                context.Response.WriteFile(

                    context.Request.MapPath("get-nodes.txt")

                );

            else

                context.Response.WriteFile(

                    context.Request.MapPath("get-subnodes.txt")

            );

 

    }

 

    public bool IsReusable

    {

        get

        {

            return false;

        }

    }

 

}

 

文档四(get-nodes.txt):返回根节点下的一级树

[{

     "text":"管理部",

     "id":"\/sext-core.js",

     "leaf":true,

     "cls":"file"

},{

     "text":"质量管理部",

     "id":"\/sext-all-debug.js",

     "leaf":true,

     "cls":"file"

},{

     "text":"产品部",

     "id":"\/sext-core-debug.js",

     "leaf":true,

     "cls":"file"

},{

     "text":"厂务部",

     "id":"\/sresources",

     "cls":"folder"

}]

 

文档五(get-subnodes.txt):返回子节点下的一级树

[{

     "text":"秘书",

     "id":"\/ssext-core.js",

     "leaf":true,

     "cls":"file"

},{

     "text":"职员",

     "id":"\/ssext-all-debug.js",

     "leaf":true,

     "cls":"file"

},{

     "text":"文员",

     "id":"\/ssext-core-debug.js",

     "leaf":true,

     "cls":"file"

}]

 

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12685933/viewspace-200319/,如需转载,请注明出处,否则将追究法律责任。

下一篇: XTemplate
请登录后发表评论 登录
全部评论

注册时间:2008-01-08

  • 博文量
    20
  • 访问量
    53142