JQuery EasyUI(9)

本文详细介绍了EasyUI框架中的Panel组件,包括其加载方式、属性列表、事件列表及方法列表,适合初学者和进阶开发者参考。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

                           第九章:Panel(面板)组件

学习要点:

  1. 加载方式
  2. 属性列表
  3. 事件列表
  4. 方法列表

一、加载方式:

1.class加载方式

<!DOCTYPE html>
<html>
  <head>
    <title>JQuery Easy UI</title>
    <meta charset="utf-8"/>
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>     
    <script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>     
    <script type="text/javascript" src="js/index.js"></script> 
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css"/>              
</head>
  <div class="easyui-panel" style="width:40px" title="面板" data-options="closable:true">
     <p>内容区域</p>
  </div>
</html>
 

2.JS调用

<!DOCTYPE html>
<html>
  <head>
    <title>JQuery Easy UI</title>
    <meta charset="utf-8"/>
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>     
    <script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>     
    <script type="text/javascript" src="js/index.js"></script> 
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css"/>              
</head>

  <!--
  <div class="easyui-panel" style="width:40px" title="面板" data-options="closable:true">
     <p>内容区域</p>
  </div>
  -->
  <div id="box">
     <p>内容区域</p>
  </div>
</html>
 
$(function(){
    $('#box').panel({
       title:'面板',
   });
});

 

二、属性列表: 

Panel属性
属性名说明
idstring面板的ID值。默认为null
titlestring面板显示的标题文本。默认为null
iconClsstring设置一个16*16图标的CSS类ID显示在面板左上角。默认为null
widthnumber设置面板宽度。默认值auto
heightnumber设置面板高度。默认值auto
leftnumber设置面板距离左边的位置(即x轴位置),默认为null
topnumber设置面板距离顶部的位置(即y轴位置),默认为null
clsstring添加一个CSS类ID到面板,默认为null
headerClsstring添加一个CSS类ID到面板头部,默认为null
bodyClsstring添加一个CSS类ID到面板正文部分,默认为null
stylesubject添加一个当前指定样式到面板。默认为{}
fitboolean当设置为true的时候面板大小将自适应父容器。默认为false
borderboolean定义是否显示面板边框,默认为true
doSizeboolean如果设置为true在面板别创建的时候将重置大小和重新布局。默认值为true。
noheaderboolean如果设置为true,将不会创建面板标题,默认为false
contentstring面板那主体内容,默认为null
collapsibleboolean定义是否显示可折叠按钮。默认为false
minimizableboolean定义是否显示最小化按钮。默认为false
maximizableboolean定义是否显示最大化按钮。默认为false
closeableboolean定义是否显示关闭按钮
toolsarray,selector自定义工具菜单,可用值:1.数组,每一个元素都包含'iconCls'和'handler' 属性。2.指向工作菜单的选择器。默认为[]
collapsedboolean定义是否在初始化的时候折叠面板。默认为false
minimizedboolean定义是否在初始化的时候最小化面板。默认为false
maximizedboolean定义是否在初始化的时候最大化面板。默认为false
closedboolean定义是否在初始化的时候关闭面板。默认为false
hrefstring从URL读取远程数据并显示到面板。默认为null
cacheboolean如果为true,在超链接载入时缓存面板内容。默认为true
loadingMessagestring在载入远程数据的时候在模板内显示一条信息。默认值为loading……
extractorfunction定义如何从ajax应答数据中提取内容,返回提取数据。
<!DOCTYPE html>
<html>
  <head>
    <title>JQuery Easy UI</title>
    <meta charset="utf-8"/>
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>     
    <script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>     
    <script type="text/javascript" src="js/index.js"></script> 
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css"/>              
</head>
<body>
  <div id="box">
     <p>内容区域</p>
  </div>

  <div id="tt">
     <a class="icon-add" onclick="javascript:alert('add')"></a>
     <a class="icon-edit" onclick="javascript:alert('edit')"></a>
     <a class="icon-cut" onclick="javascript:alert('cut')"></a>
  </div>

 </body>
</html>
 
$(function(){
    $('#box').panel({
       id:'pox',
       title:'面板',
       width:500,
       height:150,
       iconCls:'icon-search',   
       //left:100,
       //top:100,
       cls:'a',
       headerCls:'b',
       bodyCls:'c',
       style:function(){
         'min-height':'200px',
      },  
       //fit:true, 
       //boder:false,
       //doSize:false,
       //noheader:true,
       //content:'修改了',
       //collapsible:true,
       //minimizable:true,
       //maximizable:true,
       closable:true,
       tools:'#tt',
       tools:[{
          iconCls:'icon-help',
          headerCls:function(){
            alert('help');
           },
         },{
      }],

        //collapsed:true,
        //minimized:true,
        //maximized:true,
        //colsed:true,
        href:'content.php',
        loadingMessage:'加载中……',
        extractor:function(data){
         return data.substring(0,3);
         //alert(data);
       }
   });

   //$('#box').panel('panel').css('position','absolute');
});
<?php
  //content.php
  sleep(3);
  echo 123;
?>

 

三、事件列表:

Panel事件
事件名传参说明
onBeforeLoadnone在加载远程数据之前触发。
onLoadnone在加载远程数据时触发。
onBeforeOpennone在打开面板之前触发,返回false可以打开操作。
onOpennone在打开面板之后触发。
onBeforeClose none在关闭面板之前触发,返回false可以取消关闭操作。
onClosenone 在面板关闭之后触发。
onbeforeDestroynone在面板销毁之前触发,返回false可以取消销毁操作。
onDestroynone在面板销毁之后触发。
onBeforeCollapsenone在面板折叠之前触发,返回false可以终止折叠操作。
onCollapsenone在面板折叠之后触发。
onBeforeExpandnone在面板展开之前触发,返回false可以终止展开操作。
onExpandnone 在面板展开之后触发。
onResizewidth,height在面板改变大小之后触发,width:新的宽度,height:新的高度
onMoveleft,top 在面板移动之后触发。left:新的左边距位置,top:新的上边距位置
onMaximizenone在窗口最大化之后触发。
onRestorenone在窗口恢复到原始大小以后触发
onMinimizenone在窗口最小化之后触发。

 

四、方法列表:

Panel方法
方法名传参说明
optionsnone返回属性对象
panelnone返回面板对象
headernone返回面板头对象
bodynone返回面板主体对象
setTitletitle设置面板头的标题文本
openforceOpen在'forceOpen'参数设置为true的时候,打开面板时将跳过'onBeforeOpen'回调函数。
closeforceClose在'forceClose'参数设置为true的时候,关闭面板时将跳过'onBeforeClose'回调函数。
destoryforceDestory在'forceDestory'参数设置为true的时候,销毁面板时将跳过'onBeforeDestory'回调函数
refreshhref刷新面板来装载远程数据。如果'href'属性有了新的配置。它将重写旧的'href'属性。
resizeoptions设置面板大小和布局。参数对象包含下列属性:width:新的面板宽度。height:新的面板高度。left:新的面板左边距位置。top:新的面板上边距位置。
moveoptions移动面板到一个新的位置,参数对象包含下列属性:left:新的左边距位置,top:新的上边距位置。
maximizenone最大化面板到容器大小。
minimizenone最小化面板。
restorenone恢复最大化面板回到原来的大小和位置。
collapseanimate折叠面板主题
expandanimate展开面板主题
<!DOCTYPE html>
<html>
  <head>
    <title>JQuery Easy UI</title>
    <meta charset="utf-8"/>
    <script type="text/javascript" src="easyui/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>     
    <script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>     
    <script type="text/javascript" src="js/index.js"></script> 
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css"/>              
</head>
<body>
  <div id="box">
     <p>内容区域</p>
  </div>

  <div id="tt">
     <a class="icon-add" onclick="javascript:alert('add')"></a>
     <a class="icon-edit" onclick="javascript:alert('edit')"></a>
     <a class="icon-cut" onclick="javascript:alert('cut')"></a>
  </div>

 </body>
</html>
 
<?php
  //content.php
  sleep(3);
  echo 'abc';
?>
$(function(){
    $('#box').panel({
       id:'pox',
       title:'面板',
       width:500,
       height:150,
       iconCls:'icon-search',   
       //left:100,
       //top:100,
       cls:'a',
       headerCls:'b',
       bodyCls:'c',
       style:function(){
         'min-height':'200px',
      },  
       //fit:true, 
       //boder:false,
       //doSize:false,
       //noheader:true,
       //content:'修改了',
       //collapsible:true,
       //minimizable:true,
       //maximizable:true,
       closable:true,
       //tools:'#tt',
      /*
       tools:[{
          iconCls:'icon-help',
          headerCls:function(){
            alert('help');
           },
         },{
      }],
     */

       tools:[{
          iconCls:'icon-reload',
          headerCls:function(){
            //alert('help');
             $('#box').panel('refresh');
           },
         },{
      }],

        //collapsed:true,
        //minimized:true,
        //maximized:true,
        //colsed:true,
        href:'content.php',
        loadingMessage:'加载中……',
       /*
        extractor:function(data){
         return data.substring(0,3);
         //alert(data);
       },
       */
       /*
       onBeforeLoad:function(){
        alert('在远程加载之前触发!');
        return false;                //取消远程加载
      },

       onLoad:function(){
        alert('在远程加载之后触发!');
      },


       onBeforeOpen:function(){
        alert('打开之前触发!');
        return false;          //取消打开        
      },

       onOpen:function(){
        alert('打开之后触发!');
      },

       onBeforeClose:function(){
        alert('关闭之前触发!');
        return false;          //取消关闭       
      },

       onOpen:function(){
        alert('关闭之后触发!');
      },

       onBeforeDestory:function(){
        alert('销毁之前触发!');
        return false;          //取消销毁      
      },

       onDestory:function(){
        alert('销毁之后触发!');
      },

       onBeforeCollapse:function(){
        alert('折叠之前触发!');
        return false;          //取消折叠
      },

       onCollapse:function(){
        alert('折叠之后触发!');
      },

       onBeforeExpand:function(){
        alert('展开之前触发!');
        return false;          //取消展开
      },

       onExpand:function(){
        alert('展开之后触发!');
      },

       onMaximize:function(){
        alert('窗口最大化时触发!');
      },

       onRestore:function(){
        alert('窗口还原时触发!');
      },

       onMinimize:function(){
        alert('窗口最小化时触发!');
      },
      
       onResize:function(width,height){
        alert(width+'|'+height);
      },

       onMove:function(left,top){
        alert(left+'|'+top);
     },

   */
   /*
       onBeforeOpen:function(){
        alert('打开之前触发!');
        //return false;          //取消打开        
      },
   */

   });

   //$('#box').panel('panel').css('position','absolute');

   //$('#box').panel('destory');
    
   /*
     $(document).click(function(){
       $('#box').panel('resize',{
          'width':600,
          'height':300,
   });


     $(document).click(function(){
       $('#box').panel('move',{
          'left':600,
          'top':300,
   });


   */

   //console.log($('#box').panel('options'));
   //console.log($('#box').panel('panel'));
   //console.log($('#box').panel('header'));
   //console.log($('#box').panel('body'));
   //$('#box').panel('setTitle','标题');
   //$('#box').panel('open',true);
   //$('#box').panel('close');
   //$('#box').panel('destory');
   //$('#box').panel('maximize');
   //$('#box').panel('restore');
   //$('#box').panel('minimize');
   //$('#box').panel('collspse');
   //$('#box').panel('expand');
  });
});

 

 

作者:Roger_CoderLife

链接:https://blog.youkuaiyun.com/Roger_CoderLife/article/details/102853690

本文根据网易云课堂JQuery EasyUI视频教程翻译成文档,转载请注明原文出处,欢迎转载

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值