Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery EasyUI Layout Plugin - Panel

jQuery EasyUI Layout Plugin - Panel


jQuery EasyUI Plugins jQuery EasyUI Plugins


Override the defaults through $.fn.panel.defaults.

A panel is used as a container for other content. It is the foundational component for creating other components (such as Layout, Tabs, Accordion, and so on). It also provides built-in behaviors for collapsing, closing, maximizing, and minimizing, along with other custom behaviors. A panel can be easily embedded anywhere on a web page.

Usage

Creating a Panel

1. Creating a Panel from markup

It is easier to create a Panel from markup. Add the 'easyui-panel' class to

tag.



panel content.

panel content.

2. Creating a Panel programmatically

Let's create a Panel with a toolbar in the top-right corner.



panel content.

panel content.

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

Moving a Panel

Call the 'move' method to move the Panel to a new position.



$('#p').panel('move',{

    left:100,

    top:100

}); 

Loading Content

Let's load the panel content via ajax and display a message when loading succeeds.



$('#p').panel({

    href:'content_url.php',

    onLoad:function(){

        alert('loaded successfully');

    }

});

property

Name Type Description Default value
id string The id attribute of the panel. null
title string The title text displayed in the panel header. null
iconCls string A CSS class for displaying a 16x16 icon in the panel. null
width number Sets the width of the panel. auto
height number Sets the height of the panel. auto
left number Sets the left position of the panel. null
top number Sets the top position of the panel. null
cls string Adds a CSS class to the panel. null
headerCls string Adds a CSS class to the panel header. null
bodyCls string Adds a CSS class to the panel body. null
style object Adds custom-formatted styles to the panel.
 改变面板(panel)边框宽度的代码实例:     

| {}| onSelect | event | fit | boolean | When set to true, the panel (panel) resizes to fit its parent container. The example below demonstrates a panel (panel) that automatically resizes to the maximum inner size of its parent container.

    
        Embedded Panel     
| false| onSelect | event | border | boolean | Defines whether to show the border of the panel (panel). | true| onSelect | event | doSize | boolean | If set to true, the panel (panel) is resized and laid out when it is created. | true| onSelect | event | noheader | boolean | If set to true, the header of the panel (panel) will not be created. | false| onSelect | event | content | string | The main content of the panel (panel). | null| onSelect | event | collapsible | boolean | Defines whether to show the collapse button. | false| onSelect | event | minimizable | boolean | Defines whether to show the minimize button. | false| onSelect | event | maximizable | boolean | Defines whether to show the maximize button. | false| onSelect | event | closable | boolean | Defines whether to show the close button. | false| onSelect | event | tools | array,selector | Custom tool group, possible values:
1. An array, where each element contains two properties: iconCls and handler.
2. a selector, indicating the button group.

 面板(panel)工具组可通过已存在 
标签声明:

         
The panel (panel) tool group can be defined by an array:

| [] | onSelect | event | collapsed | boolean | Defines whether the panel is collapsed initially. | false| onSelect | event | minimized | boolean | Defines whether the panel is minimized initially. | false| onSelect | event | maximized | boolean | Defines whether the panel is maximized initially. | false| onSelect | event | closed | boolean | Defines whether the panel is closed initially. | false| onSelect | event | href | string | A URL from which to load remote data and display it in the panel. Note that content will not be loaded unless the panel is opened. This is useful for creating a lazily loaded panel:
Open
| null | onSelect | event | cache | boolean | Set to true to cache the panel content loaded from href. | true| onSelect | event | loadingMessage | string | A message displayed in the panel while remote data is loading. | Loading...| onSelect | event | extractor | function | Defines how to extract content from the ajax response and returns the extracted data.
extractor: function(data){

    var pattern = /]>((.|[\n\r]))/im;

    var matches = pattern.exec(data);

    if (matches){

        return matches[1];    // only extract body content

    } else {

        return data;

    }

}

| onSelect | event |

Events

Name Parameters Description
onLoad none Triggered when remote data is loaded.
onBeforeOpen none Triggered before the panel (panel) is opened; returning false stops the opening.
onOpen none Triggered after the panel (panel) is opened.
onBeforeClose none Triggered before the panel (panel) is closed; returning false cancels the closing. The panel (panel) declared below will not be closed.

    The panel cannot be closed.
| onSelect | event | onClose | none | Triggered after the panel (panel) is closed.| onSelect | event | onBeforeDestroy | none | Triggered before the panel (panel) is destroyed; returning false cancels the destruction.| onSelect | event | onDestroy | none | Triggered after the panel (panel) is destroyed.| onSelect | event | onBeforeCollapse | none | Triggered before the panel (panel) is collapsed; returning false stops the collapsing.| onSelect | event | onCollapse | none | Triggered after the panel (panel) is collapsed.| onSelect | event | onBeforeExpand | none | Triggered before the panel (panel) is expanded; returning false stops the expanding.| onSelect | event | onExpand | none | Triggered after the panel (panel) is expanded.| onSelect | event | onResize | width, height | Triggered after the panel (panel) is resized.
width: The new outer width
height: The new outer height| onSelect | event | onMove | left,top | Triggered after the panel (panel) is moved.
left: The new left position
top: The new top position| onSelect | event | onMaximize | none | Triggered after the window is maximized.| onSelect | event | onRestore | none | Triggered after the window is restored to its original size.| onSelect | event | onMinimize | none | Triggered after the window is minimized. |

Method

Name Parameters Description
options none Return the options property.
panel none Return the outer panel (panel) object.
header none Return the header object of the panel (panel).
body none Return the main body object of the panel (panel).
setTitle title Set the title text of the header.
open forceOpen When the forceOpen parameter is set to true, the panel (panel) is opened bypassing the onBeforeOpen callback function.
close forceClose When the forceClose parameter is set to true, the panel (panel) is closed bypassing the onBeforeClose callback function.
destroy forceDestroy When the forceDestroy parameter is set to true, the panel (panel) is destroyed bypassing the onBeforeDestroy callback function.
refresh href Refresh the panel (panel) to load remote data. If the 'href' parameter is assigned, the old 'href' property will be overridden.
 代码实例:     

// 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');| onSelect | event | resize | options | Resize the panel (panel) and lay it out. The Options object contains the following properties:
width: The new panel (panel) width
height: The new panel (panel) width
left: The new panel (panel) left position
top: The new panel (panel) top position

 代码实例:     

$('#pp').panel('resize',{ width: 600, height: 400 });| onSelect | event | move | options | Move the panel (panel) to a new position. The Options object contains the following properties:
left: The new panel (panel) left position
top: The new panel (panel) top position| onSelect | event | maximize | none | Fit the panel (panel) to the size of its container.| onSelect | event | minimize | none | Minimize the panel (panel).| onSelect | event | restore | none | Restore the maximized panel (panel) to its original size and position.| onSelect | event | collapse | animate | Collapse the body of the panel (panel).| onSelect | event | expand | animate | Expand the body of the panel (panel). |


jQuery EasyUI Plugins jQuery EasyUI Plugins