佐佑科技

Layout(布局)

使用$.fn.iLayout.defaults重写默认值对象。


布局容器有5个区域:北、南、东、西和中间。中间区域面板是必须的,边缘的面板都是可选的。每个边缘区域面板都可以通过拖拽其边框改变大小,也可以点击折叠按钮将面板折叠起来。布局可以进行嵌套,用户可以通过组合布局构建复杂的布局结构。


•   panel

•   resizable


创建布局


1. 通过标签创建布局


为< div/>标签增加data-toggle="topjui-layout"。


                   

2. 使用完整页面创建布局

                   
                   

3. 创建嵌套布局


注意:嵌套在内部的布局面板的左侧(西面)面板是折叠的。

                   
                   

4. 通过ajax读取内容


布局是以面板为基础创建的。所有的布局面板都支持异步加载URL内容。使用异步加载技术,用户可以使自己的布局页面显示的内容更多更快。

                   
                   

折叠布局面板

                  $('#cc').iLayout();
                  // collapse the west panel
                  $('#cc').iLayout('collapse','west');
        

添加西侧区域面板和工具菜单按钮

                   $('#cc').iLayout('add',{
                        region: 'west',
                        width: 180,
                        title: 'West Title',
                        split: true,
                        tools: [{
                            iconCls:'icon-add',
                            handler:function(){alert('add')}
                        },{
                            iconCls:'icon-remove',
                            handler:function(){alert('remove')}
                        }]
                    });
        
属性名 属性值类型 描述 默认值
fit boolean 如果设置为true,布局组件将自适应父容器。当使用'body'标签创建布局的时候,整个页面会自动最大。 false
事件名 事件参数 描述
onCollapse region 在折叠区域面板的时候触发。
onExpand region 在展开区域面板的时候触发。
onAdd region 在新增区域面板的时候触发。
onRemove region 在移除区域面板的时候触发。

区域面板属性定义与panel组件类似,下面的是公共的和新增的属性:

属性名 属性值类型 描述 默认值
title string 布局面板标题文本。 null
region string 定义布局面板位置,可用的值有:north, south, east, west, center。
border boolean 为true时显示布局面板边框。 true
split boolean 为true时用户可以通过分割栏改变面板大小。 false
iconCls string 一个包含图标的CSS类ID,该图标将会显示到面板标题上。 null
href string 用于读取远程站点数据的URL链接 null
collapsible boolean 定义是否显示折叠按钮。 true
minWidth number 最小面板宽度。 10
minHeight number 最小面板高度。 10
maxWidth number 最大面板宽度。 10000
maxHeight number 最大面板高度。 10000
expandMode string 在点击折叠面板时候的扩展模式。可用值有:“float”、“dock”和null
float:区域面板将展开并浮动在顶部,在鼠标焦点离开面板时会自动隐藏。
dock:区域面板将展开并钉在面板上,在鼠标焦点离开面板时不会自动隐藏。
null:什么也不会发生。
float
collapsedSize number 折叠后的面板大小。 28
hideExpandTool boolean 为true时隐藏折叠面板上的扩展面板工具。 false
hideCollapsedContent boolean 为true时隐藏折叠面板上的标题栏。 true
collapsedContent string,function(title) 定义在折叠面板上要显示标题内容。
1. 标题字符串;
2. 通过函数返回标题内容。

代码示例:
                            collapsedContent: function(title){
                                var region = $(this).iPanel('options').region;
                            if (region == 'north' || region == 'south'){
                                return title;
                            } else {
                                return '
                                
'+title+'
'; } }
方法名 方法参数 描述
resize param 设置布局大小。param对象包含如下属性:
width:布局宽度。
height:布局高度。
代码示例:
                            $('#cc').iLayout('resize', {
                                width:'80%',
                                height:300
                            })
                        
panel region 返回指定面板,'region'参数可用值有:'north','south','east','west','center'。
collapse region 折叠指定面板。'region'参数可用值有:'north','south','east','west'。
expand region 展开指定面板。'region'参数可用值有:'north','south','east','west'。
add options 添加指定面板。属性参数是一个配置对象,更多细节请查看选项卡面板属性。
remove region 移除指定面板。'region'参数可用值有:'north','south','east','west'。
split region 分割区域面板。'region'参数可用值有:'north','south','east','west'。

代码示例:
$("#layout").iLayout("split", "west");

unsplit region 移除指定面板。'region'参数可用值有:'north','south','east','west'。

代码示例:
$("#layout").iLayout("unsplit", "west");

联系我们
手机/微信
18973127736
办公电话
0731-89565588