<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控件的時(shí)候,利用JSON處理不是特別方便。因?yàn)榇蟛糠值膽?yīng)用的菜單都是配置在XML格式的文件中。于是,我寫了一個(gè)XML文件,利用DOM4J解析XML文件,生成JSON字符串到前臺。特殊的一點(diǎn)是,這個(gè)布局左邊是一個(gè)accordion布局,于是利用XML文件中的sub-menu進(jìn)行了配置。具體的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="權(quán)限功能管理" 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="權(quán)限功能管理" 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 王總兵 閱讀(2289) 評論(4)  編輯  收藏 所屬分類: Ext

    評論

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

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

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

    # re: Ext布局實(shí)例 2011-06-05 21:20 dfdf
    dddddddddddd  回復(fù)  更多評論
      

    主站蜘蛛池模板: 成人免费午夜视频| 中文字幕免费在线播放| 亚洲乱码在线观看| 97se亚洲国产综合自在线| 亚洲国产成AV人天堂无码| 亚洲成a人片77777群色| 亚洲国产精品成人精品软件| 亚洲午夜精品一区二区公牛电影院| 亚洲第一成年人网站| 亚洲不卡在线观看| 亚洲人成未满十八禁网站| 午夜亚洲国产理论片二级港台二级| 亚洲AV性色在线观看| 一级毛片正片免费视频手机看 | 亚洲日韩VA无码中文字幕| 亚洲一区二区三区免费| 亚洲级αV无码毛片久久精品| 国产av天堂亚洲国产av天堂| 久久亚洲AV无码精品色午夜| 亚洲国产av美女网站| 亚洲国产成人久久精品大牛影视| 国产亚洲综合视频| 成年女人A毛片免费视频| 一级毛片免费观看不卡的| 99久久久精品免费观看国产| 韩国二级毛片免费播放| 久久久久亚洲AV成人网人人网站| 久久亚洲精品成人777大小说| 亚洲av无码不卡久久| 国产精品亚洲综合网站| 两个人看的www高清免费视频| 97国产在线公开免费观看| 天天摸天天操免费播放小视频 | 最近中文字幕大全免费视频| 在线观看免费人成视频色| 国产免费看插插插视频| 国产V亚洲V天堂无码久久久| 亚洲午夜精品在线| 污污污视频在线免费观看| 无码午夜成人1000部免费视频| 欧美在线看片A免费观看|