沉睡森林@漂在北京

本处文章除注明“转载”外均为原创,转载请注明出处。

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  152 随笔 :: 4 文章 :: 114 评论 :: 0 Trackbacks
   周末对ext布局进行了研究,发现以前觉得比较麻烦的东西,现在看来十分简单。ext的使用不是特别困难,但是如何才可以保证ext可以满足各种变态的页面需求的同时又可以使开发人员不去接触一堆一堆的js呢?这个问题肯定是个难题。

   还是贴点代码。下面的代码实现了利用table模式布局FormPanel。解决了在非form模式下label不能显示的问题,但是还是存在问题,例如通常情况下“开始日期”和“结束日期”一般只占一个column,也就是两个元素各占半个column。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta name="generator" content="HTML Tidy, see www.w3.org">
        <meta http-equiv="Content-Type" content="text/html; charset=GBK">
        <title>Untitled Document</title>
        <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css"><!-- GC -->
        <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
        <script type="text/javascript" src="../../ext-all.js"></script>
    </head>
    <body>
    <script type="text/javascript">
    function getBodyWidth(){
        return document.body.clientWidth-15;
    }
   
    function func_submit_onclick(){
        alert('hello');
    }
    var _bodyWidth = getBodyWidth();
    var _columns = 3 * 2;
    var _perWidth = _bodyWidth/_columns;
   
    Ext.onReady(function(){
       
        Ext.QuickTips.init();
        var tableForm=new Ext.FormPanel({
            name:'tableForm',
            id:'tableForm',
            frame:true,
            layout:'table',
            style:'height:100%',
            layoutConfig: {columns:_columns},
            title:'TableForm',
            defaults:{border:false,layout:'form',frame:false,labelAlign:'right',labelWidth:75,width:_perWidth*2,height:30}
        });
        tableForm.add({colspan:2,items:{xtype:'textfield',fieldLabel:'First Name',anchor:'100%'}});
        tableForm.add({colspan:2,items:{xtype:'textfield',fieldLabel:'First Name',anchor:'100%'}});
        tableForm.add({colspan:2,items:{xtype:'textfield',fieldLabel:'First Name',anchor:'100%'}});
        tableForm.add({colspan:1,width:_perWidth,items:{xtype:'datefield',fieldLabel:'First Name',anchor:'100%'}});
        tableForm.add({colspan:1,width:_perWidth,labelAlign:'center',items:{xtype:'datefield',fieldLabel:'to',anchor:'100%'}});
        tableForm.add({colspan:2,items:{xtype:'textfield',fieldLabel:'First Name',anchor:'100%'}});
        tableForm.add({colspan:2,items:{xtype:'textfield',fieldLabel:'First Name',anchor:'100%'}});
        tableForm.add({colspan:4,width:_perWidth*4,items:{xtype:'textfield',fieldLabel:'First Name',anchor:'100%'}});
       
        tableForm.addButton({text:'submit',handler:func_submit_onclick});
        tableForm.addButton({text:'cancel'});
       
        tableForm.render(Ext.getBody());
    });        
    </script>
    </body>
</html>



posted on 2008-11-09 22:47 王总兵 阅读(4470) 评论(2)  编辑  收藏 所属分类: Ext

评论

# re: Ext下利用table方式布局FormPanel 2009-04-21 09:10 fas
http://ppw308593.14.112idc.com/read.php?tid=4  回复  更多评论
  

# re: Ext下利用table方式布局FormPanel 2010-08-02 15:12 madStone_l
搞一张效果图呀。  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: