ExtJs viewport & 可复用框架

 在项目里面使用ExtJs viewport定义页面框架时,各页面的框架基本相同,只有对各页面内部会有少许不同。 此文介绍我在使用ExtJs的viewport时,采用的方法。

步骤一:在公共文件ExtCustomer.js中定义区域对象

 1 var viewport;
 2
 3 ExpandedBlockStart.gifContractedBlock.gifvar leftPanel  =   {
 4    region: 'west',
 5    id: 'west-panel',
 6    contentEl: 'LeftDiv',
 7    autoScroll: true,
 8    margins: '0 0 0 0',
 9    width: 200
10}

11
12 ExpandedBlockStart.gifContractedBlock.gifvar topPanel  =   {
13    region: 'north',
14    id: 'north-panel',
15    contentEl: 'TopDiv',
16    height: 75,
17    margins: '0 0 0 0'
18}
;
19
20 ExpandedBlockStart.gifContractedBlock.gifvar bottomPanel  =   {
21    region: 'south',
22    id: 'south-panel',
23    contentEl: 'BottomDiv',
24    height: 20,
25    margins: '0 0 0 0'
26}
;
27
28 ExpandedBlockStart.gifContractedBlock.gifvar contentPanel  =   {
29    region: 'center',
30    id: 'center-panel',
31    contentEl: 'ContentDiv',
32    layout: 'fit',
33    margins: '0 0 0 0',
34    border: false
35}
;

  上面代码中定义了四个区域:页头,页脚,左侧和内容。

 

步骤二:在各页面的处理函数中,使用定义的区域对象

 

 

ContractedBlock.gif ExpandedBlockStart.gif 页面布局
ExpandedBlockStart.gifContractedBlock.gif/**//*************************************** 设置布局 *****************************************/

var cellToolBarName 
= 'ExtToolBar';

ExpandedBlockStart.gifContractedBlock.giffunction InitViewPort() 
{

    
// 主区域
    contentPanel.contentEl = null;
ExpandedSubBlockStart.gifContractedSubBlock.gif    contentPanel.items 
= {
        id: 
'row-panel',
        layout: 
'ux.row',
        bodyStyle: 
'padding:0px 0px 0px 1px',
ExpandedSubBlockStart.gifContractedSubBlock.gif        items: [
{
        id: cellToolBarName,
        contentEl: 
'cellToolbar',
        border: 
false,
        margins: 
'0 0 0 0'
ExpandedSubBlockStart.gifContractedSubBlock.gif    }
{
        contentEl: 
'cellTitle',
        border: 
false,
        margins: 
'0 0 0 0',
        height: 
20
ExpandedSubBlockStart.gifContractedSubBlock.gif    }
{
    rowHeight: 
1,
            contentEl: 
'cellDiv',
            border: 
false,
            margins: 
'0 0 0 0'
        }
]
    }
;

    
// 左侧
    leftPanel.title = '报表';
    leftPanel.collapsible 
= true;

    
// 创建区域
ExpandedSubBlockStart.gifContractedSubBlock.gif
    viewport = new Ext.Viewport({
            layout: 
'border',
            items: [
          topPanel,
          leftPanel,
          contentPanel
        ]
    }
);

    Ext.getCmp(toolBarName).hide(); 
// 隐藏工具栏
    viewport.render();  
    InitFormControlLocation();      
// 将生成Ext viewport内容,移到form下
}

  单个页面代码如上。其中给左侧区域添加标题和区域收起功能。  内容区域被划分为3个区域:工具栏,标题,报表控件,工具栏默认为隐藏状态。

  关于InitFormControlLocation函数,参考:

http://www.cnblogs.com/joyyuan97/archive/2009/02/26/1398610.html

步骤三:将页头和页脚做成UserControl,提高复用。

 

 1
 2      <!--  页头  -->
 3      < uc:PageTitle  ID ="PageTitle1"  runat ="server"  Title ="主窗体"   />
 4     
 5      <!--  主工具栏  -->
 6      < div  id ="main_ToolBar"  style ="width:240px" ></ div >  
 7     
 8      <!--  报表树  -->
 9      < div  id ="LeftDiv" ></ div >
10     
11      <!--  内容区域  -->
12      < div  id ="ContentDiv"   >
13          < div  id ="cellToolbar" ></ div >
14          < div  id ="cellTitle" > &nbsp;&nbsp; </ div >
15          < div  id ="cellDiv" >
16              < uc:CellDesign  ID ="CellDesign1"  runat ="server"   />
17          </ div >
18      </ div >
19
20      <!--  页脚  -->
21      < uc:PageBottom  ID ="PageBottom1"  runat ="server"   />

大功告成!

转载于:https://www.cnblogs.com/timy/archive/2010/07/23/1783953.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值