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

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

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

    沉睡森林@漂在北京

    本處文章除注明“轉載”外均為原創,轉載請注明出處。

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      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 王總兵 閱讀(2289) 評論(4)  編輯  收藏 所屬分類: Ext

    評論

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

    # 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级毛片大学生免费观看| 日韩精品无码免费专区网站 | 亚洲性猛交XXXX| 一级毛片大全免费播放| 亚洲国产成人久久笫一页| 一区二区三区免费视频播放器| www亚洲精品少妇裸乳一区二区| 国产成人人综合亚洲欧美丁香花| 精品免费久久久久久成人影院| 性色av极品无码专区亚洲| 免费在线观看日韩| A毛片毛片看免费| 亚洲资源在线观看| 114级毛片免费观看| 中文字幕乱码亚洲精品一区| 日韩免费三级电影| 免费夜色污私人影院网站电影| 国产偷国产偷亚洲高清日韩| 永久免费不卡在线观看黄网站| 亚洲综合一区二区国产精品| 免费A级毛片无码免费视| 国产亚洲视频在线观看| 国产精品亚洲A∨天堂不卡| 国产h肉在线视频免费观看| 亚洲熟妇成人精品一区| 精品国产人成亚洲区| 18pao国产成视频永久免费| 亚洲AⅤ男人的天堂在线观看| 中文字幕中韩乱码亚洲大片 | 国产精品1024在线永久免费 | 日本久久久免费高清| fc2免费人成在线| 亚洲国产成人精品无码区在线秒播| 卡一卡二卡三在线入口免费| 午夜免费国产体验区免费的| 亚洲高清国产拍精品26U| 精品免费国产一区二区| 99热在线免费观看| 免费播放美女一级毛片| 亚洲视频在线观看网址| www.亚洲精品.com|