EasyUi_学习之路_02

panel框架的用法:

 

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-81">
<link href="easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
<link href="easyui/themes/icon.css" rel="stylesheet" type="text/css" />
<script src="easyui/jquery-1.8.0.min.js" type="text/javascript"></script>
<script src="easyui/jquery.easyui.min.js" type="text/javascript"></script>
 <script src="easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>


<title>panel</title>
</head>
<body>
<!--   方式一 -->
  <!--   <div id="p" class="easyui-panel" title="My Panel"
    style="width:500px;height:150px;padding:10px;background:#fafafa;"
    data-options="iconCls:'icon-save',closable:true,
    collapsible:true,minimizable:true,maximizable:true">
    <p>panel content.</p>
    <p>panel content.</p>
    </div> -->
 <!--    方式二 -->
     <div id="p" style="padding:10px;">
    <p>panel content1.</p>
        </div>
    <script type="text/javascript">

    $(function(){
    $('#p').panel({
    width:500,
    height:150,
    title:'My Panel',
    tools:[{
    iconCls:'icon-add',
    handler:function(){alert('new')}
    },{
    iconCls:'icon-save',
    handler:function(){alert('save')}
    }]
    });   
   
    });
    </script>

</body>
</html>

下面是关于panel文档

Properties

NameTypeDescriptionDefault
idstringThe id attribute of this panel.null
titlestringThe title text to display in panel header.null
iconClsstringA CSS class to display a 16x16 icon in panel.null
widthnumberSet the panel width.auto
heightnumberSet the panel height.auto
leftnumberSet the panel left position.null
topnumberSet the panel top position.null
clsstringAdd a CSS class to the panel.null
headerClsstringAdd a CSS class to the panel header.null
bodyClsstringAdd a CSS class to the panel body.null
styleobjectAdd a custom specification style to the panel.

Code example to change the panel border width:

<div class="easyui-panel" style="width:200px;height:100px"
		data-options="style:{borderWidth:2}">
</div>
{}
fitbooleanWhen true to set the panel size fit it's parent container. The example below shows a panel which can be auto resized to max inner dimensions of its parent container
<div style="width:200px;height:100px;padding:5px">
	<div class="easyui-panel" style="width:200px;height:100px"
			data-options="fit:true,border:false">
		Embedded Panel
	</div>
</div>
false
borderbooleanDefines if to show panel border.true
doSizebooleanIf set to true,the panel will be resize and do layout when created.true
noheaderbooleanIf set to true, the panel header will not be created.false
contentstringThe panel body content.null
collapsiblebooleanDefines if to show collapsible button.false
minimizablebooleanDefines if to show minimizable button.false
maximizablebooleanDefines if to show maximizable button.false
closablebooleanDefines if to show closable button.false
toolsarray,selectorCustom tools, possible values:
1) an array, each element contains iconCls and handler properties.
2) a selector that indicating the tools

The panel tools can be declared with exists <div> tag:

<div class="easyui-panel" style="width:300px;height:200px"
		title="My Panel" data-options="iconCls:'icon-ok',tools:'#tt'">
</div>
<div id="tt">
	<a href="#" class="icon-add" οnclick="javascript:alert('add')"></a>
	<a href="#" class="icon-edit" οnclick="javascript:alert('edit')"></a>
</div>

The panel tools can also be defined via array:

<div class="easyui-panel" style="width:300px;height:200px"
		title="My Panel" data-options="iconCls:'icon-ok',tools:[
				{
					iconCls:'icon-add',
					handler:function(){alert('add')}
				},{
					iconCls:'icon-edit',
					handler:function(){alert('edit')}
				}]">
</div>
[]
collapsedbooleanDefines if the panel is collapsed at initialization.false
minimizedbooleanDefines if the panel is minimized at initialization.false
maximizedbooleanDefines if the panel is maximized at initialization.false
closedbooleanDefines if the panel is closed at initialization.false
hrefstringA URL to load remote data and then display in the panel. Notice that the content will not be loaded until the panel is open and expand. This is useful to create a lazy loading panel:
<div id="pp" class="easyui-panel" style="width:300px;height:200px"
		data-options="href='get_content.php',closed:true">
</div>
<a href="#" οnclick="javascript:$('#pp').panel('open')">Open</a>
null
cachebooleanTrue to cache the panel content that loaded from href.true
loadingMessagestringWhen loading remote data show a message in the panel.Loading…
extractorfunctionDefines how to extract the content from ajax response, return extracted data.
extractor: function(data){
	var pattern = /<body[^>]*>((.|[\n\r])*)<\/body>/im;
	var matches = pattern.exec(data);
	if (matches){
		return matches[1];	// only extract body content
	} else {
		return data;
	}
}
 

Events

NameParametersDescription
onLoadnoneFires when remote data is loaded.
onBeforeOpennoneFires before panel is opened, return false to stop the open.
onOpennoneFires after panel is opened.
onBeforeClosenoneFires before panel is closed, return false to cancel the close. The panel declared below cannot be closed.
<div class="easyui-panel" style="width:300px;height:200px;"
		title="My Panel" data-options="onBeforeClose:function(){return false}">
	The panel cannot be closed.
</div>
onClosenoneFires after panel is closed.
onBeforeDestroynoneFires before panel is destroyed, return false to cancel the destroy.
onDestroynoneFires after panel is destroyed.
onBeforeCollapsenoneFires before panel is collapsed, return false to stop the collapse.
onCollapsenoneFires after panel is collpased.
onBeforeExpandnoneFires before panel is expanded, return false to stop the expand.
onExpandnoneFires after panel is expanded.
onResizewidth, heightFires after panel is resized.
width: the new outer width
height: the new outer height
onMoveleft,topFires after panel is moved.
left: the new left postion
top: the new top position
onMaximizenoneFires after the window has been maximized.
onRestorenoneFires after the window has been restored to its original size.
onMinimizenoneFires after the window has been minimized.

Methods

NameParameterDescription
optionsnoneReturn options property.
panelnoneReturn the outer panel object.
headernoneReturn the panel header object.
bodynoneReturn the panel body object.
setTitletitleSet the title text of header.
openforceOpenWhen forceOpen parameter set to true, the panel is opened bypass the onBeforeOpen callback.
closeforceCloseWhen forceClose parameter set to true, the panel is closed bypass the onBeforeClose callback.
destroyforceDestroyWhen forceDestroy parameter set to true, the panel is destroyed bypass the onBeforeDestroy callback.
refreshhrefRefresh the panel to load remote data. If the 'href' parameter is assigned, it will override the old 'href' property.

Code example:

// open a panel and then refresh its contents.
$('#pp').panel('open').panel('refresh');
// refresh contents with a new URL.
$('#pp').panel('open').panel('refresh','new_content.php');
resizeoptionsSet panel size and do layout. The options object contains following properties:
width: the new panel width
height: the new panel height
left: the new panel left position
top: the new panel top position

Code example:

$('#pp').panel('resize',{
	width: 600,
	height: 400
});
moveoptionsMove the panel to a new position. The options object contains following properties:
left: the new panel left position
top: the new panel top position
maximizenoneFits the panel winthin its container.
minimizenoneMinimizing the panel.
restorenoneRestores the maximized panel back to its original size and position.
collapseanimateCollapses the panel body.
expandanimateExpand the panel body.

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值