<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    沉睡森林@漂在北京

    本處文章除注明“轉(zhuǎn)載”外均為原創(chuàng),轉(zhuǎn)載請注明出處。

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      152 隨筆 :: 4 文章 :: 114 評論 :: 0 Trackbacks
     

           最近研究了下ext,其漂亮的UI十分吸引人。但是在制作tree控件的時候,利用JSON處理不是特別方便。因為大部分的應用的菜單都是配置在XML格式的文件中。于是,我寫了一個XML文件,利用DOM4J解析XML文件,生成JSON字符串到前臺。特殊的一點是,這個布局左邊是一個accordion布局,于是利用XML文件中的sub-menu進行了配置。具體的XML格式如下:

          

    <?xml version="1.0" encoding="UTF-8"?>

    <menu-config>

          
    <sub-menu id="subMenu1" text="用戶管理">

               
    <tree id="990011" text="人員管理" href="#" leaf="true" />

               
    <tree id="990021" text="單位管理" href="#" leaf="true" />

               
    <tree id="990031" text="行政代碼管理" href="#" leaf="true" />

               
    <tree id="990041" text="用戶管理" href="#" leaf="true" />

               
    <tree id="990051" text="權限功能管理" href="#" leaf="true" />

          
    </sub-menu>

          
    <sub-menu id="subMenu2" text="采伐證管理">

               
    <tree id="990011" text="人員管理" href="#" leaf="true" />

               
    <tree id="990021" text="單位管理" href="#" leaf="true" />

               
    <tree id="990031" text="行政代碼管理" href="#" leaf="true" />

               
    <tree id="990041" text="用戶管理" href="#" leaf="true" />

               
    <tree id="990051" text="權限功能管理" href="#" leaf="true" />

          
    </sub-menu>

    </menu-config>

           最終頁面效果如下示:

           代碼比較多,不能全部貼出來,最核心的JS貼出來看看。

    Ext.onReady(function() {

          Ext.state.Manager.setProvider(
    new Ext.state.CookieProvider());

          Ext.Ajax.request(
    {

               url : 
    "txn900002.do",

               method : 
    "get",

               success : 
    function(response, options) {

                     
    var array = Ext.util.JSON.decode(response.responseText);

                     
    for (var i = 0; i < array.length; i++{

                          
    var obj = array[i];

                          accordion.add(
    {

                                id : obj.id,

                                title : obj.text,

                                html : 
    "<div   align=left valign=top    id=" + obj.id

                                           
    + "></div>"

                          }
    );

                          accordion.doLayout(
    true);

                          buildTree(obj.id);

                     }


               }


          }
    );

          
    var tab = new Ext.TabPanel({

               region : 
    "center",

               margins : 
    "0 5 0 0",

               deferredRender : 
    false,

               activeTab : 
    0,

               resizeTabs : 
    true,

               enableTabScroll : 
    true

          }
    );

          tab.add(
    {

               id : 
    "welcome",

               title : 
    "welcome",

               html : 
    "<hr><h1>hello world</h1>"

          }
    );

          
    function treeClick(node, e) {

               
    if (!node.isLeaf()) {

                     e.stopEvent();

               }
     else {

                     
    var n = tab.getComponent(node.id);

                     alert(node.href);

                     
    if (!n) {

                          
    var n = tab.add({

                                
    "id" : node.id,

                                
    "title" : node.text,

                                closable : 
    true,

                                html : 
    "<iframe src=txn" + node.id

                                           
    + ".do   style='width:100%;height:100%' ></iframe>"

                          }
    );

                     }


                     tab.setActiveTab(n);

               }


          }


          
    function buildTree(subMenuId) {

               
    var root = new Ext.tree.AsyncTreeNode({

                     text : 
    "Autos",

                     draggable : 
    false,

                     id : 
    "source"

               }
    );

               
    var tree = new Ext.tree.TreePanel({

                     el : subMenuId,

                     border : 
    0,

                     animate : 
    true,

                     enableDD : 
    false,

                     loader : 
    new Ext.tree.TreeLoader({

                          dataUrl : 
    "txn900001.do?subMenuId=" + subMenuId,

                          requestMethod : 
    "GET"

                     }
    ),

                     root : root,

                     rootVisible : 
    false,

                     autoHeight : 
    true,

                     containerScroll : 
    false

               }
    );

               tree.render(subMenuId);

               root.expand();

               tree.on(
    "click", treeClick);

          }


          
    var header = new Ext.Panel({

               region : 
    "north",

               margins : 
    "0 5 0 5",

               height : 
    80,

               collapsible : 
    true,

               split : 
    true,

               minSize : 
    80,

               maxSize : 
    80

          }
    );

          
    var status = new Ext.Panel({

               region : 
    "south",

               margins : 
    "0 5 5 5",

               height : 
    20,

               minSize : 
    20,

               maxSize : 
    20,

               split : 
    true

          }
    );

          
    var accordion = new Ext.Panel({

               region : 
    "west",

               margins : 
    "0 0 0 5",

               split : 
    true,

               width : 
    210,

               layout : 
    "accordion",

               autoScroll : 
    true,

               animCollapse : 
    false,

               animate : 
    true,

               layoutConfig : 
    {

                     animate : 
    true

               }


          }
    );

          
    var viewport = new Ext.Viewport({

               layout : 
    "border",

               items : [header, status, accordion, tab]

          }
    );

    }
    );
    posted on 2008-11-01 19:39 王總兵 閱讀(2302) 評論(4)  編輯  收藏 所屬分類: Ext

    評論

    # re: Ext布局實例[未登錄] 2008-12-01 21:55 人在旅途
    不錯哦,繼續(xù)加油  回復  更多評論
      

    # re: Ext布局實例 2009-06-10 11:40 mmxida
    謝謝您的講解  回復  更多評論
      

    # re: Ext布局實例[未登錄] 2009-11-18 17:21 aa
    ext不能直接讀xml?  回復  更多評論
      

    # re: Ext布局實例 2011-06-05 21:20 dfdf
    dddddddddddd  回復  更多評論
      

    主站蜘蛛池模板: 日韩免费视频在线观看| 四虎精品视频在线永久免费观看| 日本一线a视频免费观看| 亚洲日韩中文字幕| 免费国产作爱视频网站| 亚洲成a人片在线看| 免费无码又黄又爽又刺激| 亚洲乱码卡三乱码新区| 国产h视频在线观看网站免费| 亚洲AV无码乱码在线观看裸奔| 99麻豆久久久国产精品免费 | 亚洲国产精品张柏芝在线观看 | 中国videos性高清免费| 亚洲美女高清一区二区三区 | 中国一级特黄高清免费的大片中国一级黄色片 | 中文字幕无码免费久久9一区9| 久久99亚洲综合精品首页| 精品无码国产污污污免费网站国产| 亚洲日韩在线第一页| 国产无遮挡无码视频免费软件| 亚洲精品无码久久久久久久 | 亚洲成a人片在线观看中文动漫| 久久w5ww成w人免费| 亚洲国产品综合人成综合网站 | 亚洲AⅤ无码一区二区三区在线 | 青青青国产在线观看免费| 亚洲日韩一区二区一无码| 免费一级毛片在级播放| 最新久久免费视频| 精品亚洲麻豆1区2区3区| 思思99re66在线精品免费观看| 黄色一级视频免费观看| 亚洲av激情无码专区在线播放 | 99re热免费精品视频观看| 美美女高清毛片视频黄的一免费| 国产成人亚洲精品狼色在线| 国产中文字幕免费| 三上悠亚电影全集免费| 亚洲午夜精品在线| 亚洲一级片免费看| 在线观看H网址免费入口|