Base
Parser
Usage
- $.parser.parse(); // parse all the page
- $.parser.parse('#cc'); // parse the specified node
$.parser.parse(); // parse all the page
$.parser.parse('#cc'); // parse the specified node
Properties
Name | Type | Description | Default |
$.parser.auto | boolean | Defines if to auto parse the easyui component. | true |
Events
Name | Parameters | Description |
$.parser.onComplete | context | Fires when parser finishing its parse action. |
Methods
Name | Parameter | Description |
$.parser.parse | context | Parse the easyui component. |
EasyLoader
Usage
- easyloader.base = '../'; // set the easyui base directory
- easyloader.load('messager', function(){ // load the specified module
- $.messager.alert('Title', 'load ok');
- });
easyloader.base = '../'; // set the easyui base directory
easyloader.load('messager', function(){ // load the specified module
$.messager.alert('Title', 'load ok');
});
Properties
Name | Type | Description | Default |
modules | object | Predefined modules. | |
locales | object | Predefined locales. | |
base | string | The easyui base directory, must end with '/'. | The base directory will be auto setted relative to easyload.js |
theme | string | The name of theme that defined in 'themes' directory | default |
css | boolean | Defines if loading css file when loading module | true |
locale | string | The locale name | null |
timeout | number | Timeout value in milliseconds. Fires if a timeout occurs. | 2000 |
Defined locales
- af
- bg
- ca
- cs
- da
- de
- en
- fr
- nl
- zh_CN
- zh_TW
Events
Name | Parameters | Description |
onProgress | name | Fires when a module is loaded successfully. |
onLoad | name | Fires when a module and it's dependencies are loaded successfully. |
Methods
Name | Parameter | Description |
load | module, callback | Load the specified module. When load success a callback function will be called. |
Draggable
Override defaults with $.fn.draggable.defaults.
Usage
- <div id="dd" style="width:100px;height:100px;">
- <div id="title" style="background:#ccc;">title</div>
- </div>
- $('#dd').draggable({
- handle:'#title'
- });
Properties
Name | Type | Description | Default |
proxy | string,function | A proxy element to be used when dragging, when set to 'clone', a clone element is used as proxy. If a function is specified, it must return a jQuery object. | null |
revert | boolean | If set to true, the element will return to its start position when dragging stops. | false |
cursor | string | The css cursor when dragging. | move |
deltaX | number | The dragged element position x corresponding to current cursor | null |
deltaY | number | The dragged element position y corresponding to current cursor | null |
handle | selector | The handle that start the draggable. | null |
disabled | boolean | True to stop draggable. | false |
edge | number | The drag width in which can start draggable. | 0 |
axis | string | Defines the axis which the dragged elements moves on, available value is 'v' or 'h', when set to null will move across 'v' and 'h' direction. | null |
Events
Name | Parameters | Description |
onBeforeDrag | e | Fires before dragging, return false to cancel this dragging. |
onStartDrag | e | Fires when the target object start dragging. |
onDrag | e | Fires during dragging. Return false will not do dragging actually. |
onStopDrag | e | Fires when the dragging stops. |
Methods
Name | Parameter | Description |
options | none | Return the options property. |
proxy | none | Return the drag proxy if the proxy property is setted. |
enable | none | Enable the drag action. |
disable | none | Disable the drag action. |
Droppable
Override defaults with $.fn.droppable.defaults.
Usage
- <div id="dd" style="width:100px;height:100px;"></div>
- $('#dd').droppable({
- accept:'#d1,#d3'
- });
Properties
Name | Type | Description | Default |
accept | selector | Determine which draggable element will be accepted | null |
Events
Name | Parameters | Description |
onDragEnter | e,source | Fires when the draggable element is dragged enter. The source parameter indicate the dragged DOM element. |
onDragOver | e,source | Fires when the draggable element is dragged over. The source parameter indicate the dragged DOM element. |
onDragLeave | e,source | Fires when the draggable element is dragged leave. The source parameter indicate the dragged DOM element. |
onDrop | e,source | Fires when the draggable element is dropped. The source parameter indicate the dragged DOM element. |
Resizable
Override defaults with $.fn.resizable.defaults.
Usage
- <div id="rr" style="width:100px;height:100px;border:1px solid #ccc;"></div>
- $('#rr').resizable({
- maxWidth:800,
- maxHeight:600
- });
Properties
Name | Type | Description | Default |
disabled | boolean | True to disable resizing. | false |
handles | string | Indicate the direction of resizable,'n' is the north,'e' is the east,etc. | n, e, s, w, ne, se, sw, nw, all |
minWidth | number | The minimum width when resizing. | 10 |
minHeight | number | The minimum height when resizing. | 10 |
maxWidth | number | The maximum width when resizing. | 10000 |
maxHeight | number | The maximum height when resizing. | 10000 |
edge | number | The edge of border to be resized. | 5 |
Events
Name | Parameters | Description |
onStartResize | e | Fires when start resizing. |
onResize | e | Fires during resizing. When return false, the DOM element will not acts actual resize action. |
onStopResize | e | Firest when stop resizing. |
Pagination
Override defaults with $.fn.pagination.defaults.
Dependencies
- linkbutton
Usage
- <div id="pp" style="background:#efefef;border:1px solid #ccc;"></div>
- $('#pp').pagination({
- total:2000,
- pageSize:10
- });
Properties
Name | Type | Description | Default |
total | number | The total records, which should be setted when pagination is created. | 1 |
pageSize | number | The page size. | 10 |
pageNumber | number | Show the page number when pagination is created. | 1 |
pageList | array | User can change the page size. The pageList property defines how many size can be changed. | [10,20,30,50] |
loading | boolean | Defines if data is loading. | false |
buttons | array | Defines custom buttons, each button contains two properties: | null |
showPageList | boolean | Defines if to show page list. | true |
showRefresh | boolean | Defines if to show refresh button. | true |
beforePageText | string | Show a label before the input component. | Page |
afterPageText | string | Show a label after the input component. | of {pages} |
displayMsg | string | Display a page information. | Displaying {from} to {to} of {total} items |
Events
Name | Parameters | Description |
onSelectPage | pageNumber, pageSize | Fires when user select a new page. callback function contains two parameter: |
onBeforeRefresh | pageNumber, pageSize | Fires before the refresh button is clicked, return false to cancel the refresh action. |
onRefresh | pageNumber, pageSize | Fires after refresh. |
onChangePageSize | pageSize | Fires when user change the page size. |
Methods
Name | Parameter | Description |
options | none | Return the options object. |
loading | none | Make the pagination to become loading status. |
loaded | none | Make the pagination to become loaded status. |
SearchBox
Override defaults with $.fn.searchbox.defaults.
Dependencies
- menubutton
Usage Example
Create SearchBox
1. Create from markup. Add 'easyui-searchbox' class to <input/> markup.
- <script type="text/javascript">
- function qq(value,name){
- alert(value+":"+name)
- }
- </script>
- <input id="ss" class="easyui-searchbox"
- searcher="qq"
- prompt="Please Input Value" menu="#mm" style="width:300px"></input>
- <div id="mm" style="width:120px">
- <div name="all" iconCls="icon-ok">All News</div>
- <div name="sports">Sports News</div>
- </div>
2. Create programatically.
- <input id="ss"></input>
- <div id="mm" style="width:120px">
- <div name="all" iconCls="icon-ok">All News</div>
- <div name="sports">Sports News</div>
- </div>
- $('#ss').searchbox({
- width:200,
- searcher:function(value,name){
- alert(value + "," + name)
- },
- menu:'#mm',
- prompt:'Please Input Value'
- });
Properties
Name | Type | Description | Default |
width | number | Set the component width. | auto |
propmt | string | The prompt message to be displayed in input box. | '' |
value | string | The inputed value. | '' |
menu | selector | The search type menu. | null |
searcher | function(value,name) | The searcher function that will be called when user presses the searching button or press ENTER key. | null |
Methods
Name | Parameter | Description |
options | none | Return the options object. |
menu | none | Return the search type menu object. |
textbox | none | Return the text box object. |
getValue | none | Return the current searching value. |
setValue | value | Set a new searching value. |
getName | none | Return the current searching type name. |
destroy | none | Destroy this component. |
resize | width | Reset the component width. |
ProgressBar
Override defaults with $.fn.progressbar.defaults.
Dependencies
- none
Usage Example
Create ProgressBar
The ProgressBar component can be created from html markup or programatically. Creation from markup is even easier. Add 'easyui-progressbar' class to <div/> markup.
- <div id="p" class="easyui-progressbar" style="width:400px;"></div>
Get or Set Value
We get the current value and set a new value for this component.
- var value = $('#p').progressbar('getValue');
- if (value < 100){
- value += Math.floor(Math.random() * 10);
- $('#p').progressbar('setValue', value);
- }
Properties
Name | Type | Description | Default |
width | string | Set the progressbar width. | auto |
value | number | The percentage value. | 0 |
text | string | The text template to be displayed on component. | {value}% |
Events
Name | Parameters | Description |
onChange | newValue,oldValue | Fires when the value is changed. |
Methods
Name | Parameter | Description |
options | none | Return the options object. |
resize | width | Resize the component. |
getValue | none | Return the current progress value. |
setValue | value | Set a new progress value. |
Layout
Panel
Override defaults with $.fn.panel.defaults.
Usage Example
Create Panel
1. Create Panel via markup
Creation from markup is even easier. Add 'easyui-panel' class to <div/> markup.
- <div id="p" class="easyui-panel" title="My Panel" style="width:500px;height:150px;padding:10px;background:#fafafa;"
- iconCls="icon-save" closable="true"
- collapsible="true" minimizable="true" maximizable=true>
- <p>panel content.</p>
- <p>panel content.</p>
- </div>
2. Create Panel programatically
Let's create panel with tools on top right.
- <div id="p" style="padding:10px;">
- <p>panel content.</p>
- <p>panel content.</p>
- </div>
- $('#p').panel({
- width:500,
- height:150,
- title: 'My Panel',
- tools: [{
- iconCls:'icon-add',
- handler:function(){alert('new')}
- },{
- iconCls:'icon-save'
- handler:function(){alert('save')}
- }]
- });
Move Panel
Call 'move' method to move panel to a new position
- $('#p').panel('move',{
- left:100,
- top:100
- });
Load Content
Let's load the panel content via ajax and show some message when loaded successfully.
- $('#p').panel({
- href:'content_url.php',
- onLoad:function(){
- alert('loaded successfully');
- }
- });
Properties
Name | Type | Description | Default |
title | string | The title text to display in panel header. | null |
iconCls | string | A CSS class to display a 16x16 icon in panel. | null |
width | number | Set the panel width. | auto |
height | number | Set the panel height. | auto |
left | number | Set the panel left position. | null |
top | number | Set the panel top position. | null |
cls | string | Add a CSS class to the panel. | null |
headerCls | string | Add a CSS class to the panel header. | null |
bodyCls | string | Add a CSS class to the panel body. | null |
style | object | Add a custom specification style to the panel. | {} |
fit | boolean | When true to set the panel size fit it's parent container. | false |
border | boolean | Defines if to show panel border. | true |
doSize | boolean | If set to true,the panel will be resize and do layout when created. | true |
noheader | boolean | If set to true, the panel header will not be created. | false |
content | string | The panel body content. | null |
collapsible | boolean | Defines if to show collapsible button. | false |
minimizable | boolean | Defines if to show minimizable button. | false |
maximizable | boolean | Defines if to show maximizable button. | false |
closable | boolean | Defines if to show closable button. | false |
tools | array | Custom tools, every tool can contain two properties: iconCls and handler | [] |
collapsed | boolean | Defines if the panel is collapsed at initialization. | false |
minimized | boolean | Defines if the panel is minimized at initialization. | false |
maximized | boolean | Defines if the panel is maximized at initialization. | false |
closed | boolean | Defines if the panel is closed at initialization. | false |
href | string | A URL to load remote data and then display in the panel. | null |
cache | boolean | True to cache the panel content that loaded from href. | true |
loadingMessage | string | When loading remote data show a message in the panel. | Loading… |
extractor | function | Defines 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
Name | Parameters | Description |
onLoad | none | Fires when remote data is loaded. |
onBeforeOpen | none | Fires before panel is opened, return false to stop the open. |
onOpen | none | Fires after panel is opened. |
onBeforeClose | none | Fires before panel is closed, return false to cancel the close. |
onClose | none | Fires after panel is closed. |
onBeforeDestroy | none | Fires before panel is destroyed, return false to cancel the destroy. |
onDestroy | none | Fires after panel is destroyed. |
onBeforeCollapse | none | Fires before panel is collapsed, return false to stop the collapse. |
onCollapse | none | Fires after panel is collpased. |
onBeforeExpand | none | Fires before panel is expanded, return false to stop the expand. |
onExpand | none | Fires after panel is expanded. |
onResize | width, height | Fires after panel is resized. |
onMove | left,top | Fires after panel is moved. |
onMaximize | none | Fires after the window has been maximized. |
onRestore | none | Fires after the window has been restored to its original size. |
onMinimize | none | Fires after the window has been minimized. |
Methods
Name | Parameter | Description |
options | none | Return options property. |
panel | none | Return the panel object. |
header | none | Return the panel header object. |
body | none | Return the panel body object. |
setTitle | title | Set the title text of header. |
open | forceOpen | When forceOpen parameter set to true, the panel is opened bypass the onBeforeOpen callback. |
close | forceClose | When forceClose parameter set to true, the panel is closed bypass the onBeforeClose callback. |
destroy | forceDestroy | When forceDestroy parameter set to true, the panel is destroyed bypass the onBeforeDestroy callback. |
refresh | href | Refresh the panel to load remote data when href property is setted. |
resize | options | Set panel size and do layout. The options object contains following properties: |
move | options | Move the panel to a new position. The options object contains following properties: |
maximize | none | Fits the panel winthin its container. |
minimize | none | Minimizing the panel. |
restore | none | Restores the maximized panel back to its original size and position. |
collapse | animate | Collapses the panel body. |
expand | animate | Expand the panel body. |
Tabs
Override defaults with $.fn.tabs.defaults.
Dependencies
- panel
- linkbutton
Usage Example
Create tabs
1. Create tabs via markup
Create tabs from markup is even easier, we don't need to write any JavaScript code. Remember to add 'easyui-panel' class to <div/> markup. Each tab panel is created via sub <div/> markup, the usage is same as panel.
- <div id="tt" class="easyui-tabs" style="width:500px;height:250px;">
- <div title="Tab1" style="padding:20px;display:none;">
- tab1
- </div>
- <div title="Tab2" closable="true" style="overflow:auto;padding:20px;display:none;">
- tab2
- </div>
- <div title="Tab3" iconCls="icon-reload" closable="true" style="padding:20px;display:none;">
- tab3
- </div>
- </div>
2. Create tabs programatically
Now we create tabs programatically, we catch the 'onSelect' event also.
- $('#tt').tabs({
- border:false,
- onSelect:function(title){
- alert(title+' is selected');
- }
- });
Add new tab panel
- // add a new tab panel
- $('#tt').tabs('add',{
- title:'New Tab',
- content:'Tab Body',
- closable:true
- });
Get the selected Tab
- // get the selected tab panel and its tab object
- var pp = $('#tt').tabs('getSelected');
- var tab = pp.panel('options').tab; // the corresponding tab object
Properties
Name | Type | Description | Default |
width | number | The width of tabs container. | auto |
height | number | The height of tabs container. | auto |
plain | boolean | True to render the tab strip without a background container image. | false |
fit | boolean | True to set the size of tabs container to fit it's parent container. | false |
border | boolean | True to show tabs container border. | true |
scrollIncrement | number | The number of pixels to scroll each time a tab scroll button is pressed. | 100 |
scrollDuration | number | The number of milliseconds that each scroll animation should last. | 400 |
tools | array | The right toolbar, each tool options is same as linkbutton. | null |
Events
Name | Parameters | Description |
onLoad | panel | Fires when an ajax tab panel finish loading remote data. |
onSelect | title | Fires when user select a tab panel. |
onBeforeClose | title | Fires before the tab panel is closed, return false to cancel this close action. |
onClose | title | Fires when user close a tab panel. |
onAdd | title | Fires when a new tab panel is added. |
onUpdate | title | Fires when a tab panel is updated. |
onContextMenu | e, title | Fires when a tab panel is right clicked. |
Methods
Name | Parameter | Description |
options | none | Return the tabs options. |
tabs | none | Return all tab panels. |
resize | none | Resize the tabs container and do layout. |
add | options | Add a new tab panel, the options parameter is a config object, see tab panel properties for more details. |
close | title | Close a tab panel, title parameter indicate which panel to be closed. |
getTab | title | Get the specified tab panel. |
getSelected | none | Get the selected tab panel. |
select | title | Select a tab panel. |
exists | title | Indicate if the special panel is exists. |
update | param | Update the specified tab panel, the param parameter contains two properties: |
Tab Panel
The tab panel properties is defined in panel component, below is some common properties.
Name | Type | Description | Default |
title | string | The tab panel title text. | |
content | string | The tab panel content. | |
href | string | A URL to load remote content to fill the tab panel. | null |
cache | boolean | True to cache the tab panel, valid when href property is setted. | true |
iconCls | string | An icon CSS class to show on tab panel title. | null |
width | number | The width of tab panel. | auto |
height | number | The height of tab panel. | auto |
Some added properties.
Name | Type | Description | Default |
closable | boolean | When set to true, the tab panel will show a closable button which can click to close the tab panel. | false |
selected | boolean | When set to true, tab tab panel will be selected. | false |
Accordion
Override defaults with $.fn.accordion.defaults.
Dependencies
- panel
Usage Example
Create Accordion
Create accordion via markup, add 'easyui-accordion' class to <div/> markup.
- <div id="aa" class="easyui-accordion" style="width:300px;height:200px;">
- <div title="Title1" iconCls="icon-save" style="overflow:auto;padding:10px;">
- <h3 style="color:#0099FF;">Accordion for jQuery</h3>
- <p>Accordion is a part of easyui framework for jQuery.
- It lets you define your accordion component on web page more easily.</p>
- </div>
- <div title="Title2" iconCls="icon-reload" selected="true" style="padding:10px;">
- content2
- </div>
- <div title="Title3">
- content3
- </div>
- </div>
We can change or recreate accordion later and modify some features.
- $('#aa').accordion({
- animate:false
- });
Refresh Accordion Panel Content
Call 'getSelected' method to get the current panel and then we can call 'refresh' method of panel to load new content.
- var pp = $('#aa').accordion('getSelected'); // get the selected panel
- if (pp){
- pp.panel('refresh','new_content.php'); // call 'refresh' method to load new content
- }
Container Options
Name | Type | Description | Default |
width | number | The width of accordion container. | auto |
height | number | The height of accordion container. | auto |
fit | boolean | Set to true to set the accordion container size fit it's parent container. | false |
border | boolean | Defines if to show the border. | true |
animate | boolean | Defines if to show animation effect when expand or collapse panel. | true |
Panel Options
The accordion panel options is inhirited from panel, below is the addition properties:
Name | Type | Description | Default |
selected | boolean | Set to true to expand the panel. | false |
Events
Name | Parameters | Description |
onSelect | title | Fires when a panel is selected. |
onAdd | title | Fires when a new panel is added. |
onBeforeRemove | title | Fires before a panel is removed, return false to cancel the remove action. |
onRemove | title | Fires when a panel is removed. |
Methods
Name | Parameter | Description |
options | none | Return the options of accordion. |
panels | none | Get all panels. |
resize | none | Resize the accordion. |
getSelected | none | Get the selected panel. |
getPanel | title | Get the specified panel. |
select | title | Select the specified panel. |
add | options | Add a new panel. |
remove | title | Remove the specified panel. |
Layout
Dependencies
- panel
- resizable
Usage Example
Create Layout
Create Layout via markup. Add 'easyui-layout' class to <div/> markup.
- <div id="cc" class="easyui-layout" style="width:600px;height:400px;">
- <div region="north" title="North Title" split="true" style="height:100px;"></div>
- <div region="south" title="South Title" split="true" style="height:100px;"></div>
- <div region="east" iconCls="icon-reload" title="East" split="true" style="width:100px;"></div>
- <div region="west" split="true" title="West" style="width:100px;"></div>
- <div region="center" title="center title" style="padding:5px;background:#eee;"></div>
- </div>
Create layout on whole page.
- <body class="easyui-layout">
- <div region="north" title="North Title" split="true" style="height:100px;"></div>
- <div region="south" title="South Title" split="true" style="height:100px;"></div>
- <div region="east" iconCls="icon-reload" title="East" split="true" style="width:100px;"></div>
- <div region="west" split="true" title="West" style="width:100px;"></div>
- <div region="center" title="center title" style="padding:5px;background:#eee;"></div>
- </body>
Collpase Layout Panel
- $('#cc').layout();
- // collapse the west panel
- $('#cc').layout('collapse','west');
Layout Panel Options
Name | Type | Description | Default |
title | string | The layout panel title text. | null |
region | string | Defines the layout panel position, the value is one of following: north, south, east, west, center. | |
border | boolean | True to show layout panel border. | true |
split | boolean | True to show a split bar which user can change the panel size. | false |
iconCls | string | An icon CSS class to show a icon on panel header. | null |
href | string | An URL to load data from remote site. | null |
Methods
Name | Parameter | Description |
resize | none | Set the layout size. |
panel | region | Return the specified panel, the 'region' parameter possible values:'north','south','east','west','center'. |
collapse | region | Collapse the specified panel, the 'region' parameter possible values:'north','south','east','west'. |
expand | region | Expand the specified panel, the 'region' parameter possible values:'north','south','east','west'. |
Menu and Button
Menu
Override defaults with $.fn.menu.defaults.
Usage Example
Create Menu
Create menu via markup should add 'easyui-menu' class to <div/> markup. Each menu item is created via <div/> markup. We can add 'iconCls' attribute to menu item to define a icon that will display on left of menu item. Add 'menu-sep' class to menu item will generate a menu seperator.
- <div id="mm" class="easyui-menu" style="width:120px;">
- <div>New</div>
- <div>
- <span>Open</span>
- <div style="width:150px;">
- <div><b>Word</b></div>
- <div>Excel</div>
- <div>PowerPoint</div>
- </div>
- </div>
- <div iconCls="icon-save">Save</div>
- <div class="menu-sep"></div>
- <div>Exit</div>
- </div>
Create menu programatically and listening the 'onClick' event.
- $('#mm').menu({
- onClick:function(item){
- //...
- }
- });
Show Menu
When menu is created, it's hidden and not visible. Call 'show' method to display menu.
- $('#mm').menu('show', {
- left: 200,
- top: 100
- });
Properties
Name | Type | Description | Default |
zIndex | number | Menu z-index style,increase from it. | 110000 |
left | number | Menu left position. | 0 |
top | number | Menu top position. | 0 |
Events
Name | Parameters | Description |
onShow | none | Fires after menu is showed. |
onHide | none | Fires after menu is hidden. |
onClick | item | Fires when the menu item is clicked. |
Methods
Name | Parameter | Description |
show | pos | Show a menu on specified position. |
hide | none | Hide a menu. |
getItem | itemEl | Get the menu item data and return it, the data contains the following properties: |
setText | param | Set the specified menu item text. The 'param' parameter contains two properties: |
setIcon | param | Set the specified menu item icon. The 'param' parameter contains two properties: |
findItem | text | Find the specified menu item, the return object is same as the getItem method. |
appendItem | param | Append menu item, the 'param' parameter contains the following properties: |
removeItem | itemEl | Remove the specified menu item. |
enableItem | itemEl | Enable the menu item. |
disableItem | itemEl | Disable the menu item. |
LinkButton
Override defaults with $.fn.linkbutton.defaults.
Usage Example
- <a href="#" id="btn" iconCls="icon-search">easyui</a>
- $('#btn').linkbutton({
- plain:true
- });
- $('#btn').linkbutton('disable'); // disable the button
- $('#btn').linkbutton('enable'); // enable the button
Properties
Name | Type | Description | Default |
id | string | The id attribute of this component. | null |
disabled | boolean | True to disable the button | false |
plain | boolean | True to show a plain effect. | false |
text | string | The button text. | '' |
iconCls | string | A CSS class to display a 16x16 icon on left. | null |
Methods
Name | Parameter | Description |
options | none | Return options property. |
disable | none | Disable the button |
enable | none | Enable the button |
MenuButton
Extend from $.fn.linkbutton.defaults. Override defaults with $.fn.menubutton.defaults.
Dependencies
- menu
- linkbutton
Usage
- <a href="javascript:void(0)" id="mb" iconCls="icon-edit">Edit</a>
- <div id="mm" style="width:150px;">
- <div iconCls="icon-undo">Undo</div>
- <div iconCls="icon-redo">Redo</div>
- <div class="menu-sep"></div>
- <div>Cut</div>
- <div>Copy</div>
- <div>Paste</div>
- <div class="menu-sep"></div>
- <div iconCls="icon-remove">Delete</div>
- <div>Select All</div>
- </div>
- $('#mb').menubutton({
- menu: '#mm'
- });
Properties
The properties extend from linkbutton, below is the added properties for menubutton.
Name | Type | Description | Default |
plain | boolean | True to show plain effect. | true |
menu | string | A selector to create a corresponding menu. | null |
duration | number | Defines duration time in milliseconds to show menu when hovering the button. | 100 |
Methods
Name | Parameter | Description |
options | none | Return the options object. |
disable | none | Disable the menubutton. |
enable | none | Enable the menubutton. |
SplitButton
Extend from $.fn.linkbutton.defaults. Override defaults with $.fn.splitbutton.defaults.
Dependencies
- menu
- linkbutton
Usage
- <a href="javascript:void(0)" id="sb" iconCls="icon-ok" οnclick="javascript:alert('ok')">Ok</a>
- <div id="mm" style="width:100px;">
- <div iconCls="icon-ok">Ok</div>
- <div iconCls="icon-cancel">Cancel</div>
- </div>
- $('#sb').splitbutton({
- menu:'#mm'
- });
Properties
The properties extend from linkbutton, below is the added properties for splitbutton.
Name | Type | Description | Default |
plain | boolean | True to show plain effect. | true |
menu | string | A selector to create a corresponding menu. | null |
duration | number | Defines duration time in milliseconds to show menu when hovering the button. | 100 |
Methods
Name | Parameter | Description |
options | none | Return the options object. |
disable | none | Disable the splitbutton. |
enable | none | Enable the splitbutton. |
Form
Form
Usage
- <form id="ff" method="post">
- ...
- </form>
To make the form become ajax submit form
- $('#ff').form({
- url:...,
- onSubmit: function(){
- // do some check
- // return false to prevent submit;
- },
- success:function(data){
- alert(data)
- }
- });
- // submit the form
- $('#ff').submit();
To do a submit action
- // call 'submit' method of form plugin to submit the form
- $('#ff').form('submit', {
- url:...,
- onSubmit: function(){
- // do some check
- // return false to prevent submit;
- },
- success:function(data){
- alert(data)
- }
- });
Properties
Name | Type | Description | Default |
url | string | The form action URL to submit | null |
Events
Name | Parameters | Description |
onSubmit | none | Fires before submit, return false to prevent submit action. |
success | data | Fires when the form is submitted successfuly. |
onBeforeLoad | param | Fires before a request is made to load data. Return false to cancel this action. |
onLoadSuccess | data | Fires when the form data is loaded. |
onLoadError | none | Fires when some errors occur while loading form data. |
Methods
Name | Parameter | Description |
submit | options | Do the submit action, the options parameter is a object which contains following properties: |
load | data | Load records to fill the form. |
clear | none | Clear the form data |
validate | none | Do the form fields validation, return true when all fields is valid. The method is used with the validatebox plugin. |
ValidateBox
Override defaults with $.fn.validatebox.defaults.
Usage
- <input id="vv" required="true" validType="email">
- $('#vv').validatebox({
- required:true
- });
Validate Rule
The validate rule is defined by using required and validType property, here are the rules already implemented:
- email: Match email regex rule.
- url: Match URL regex rule.
- length[0,100]: Between x and x characters allowed.
- remote['http://.../action.do','paramName']: Send ajax request to do validate value, return 'true' when successfully.
To custom validate rule, override $.fn.validatebox.defaults.rules that defines a validator function and invalid message. For example, to define a minLength valid type:
- $.extend($.fn.validatebox.defaults.rules, {
- minLength: {
- validator: function(value, param){
- return value.length >= param[0];
- },
- message: 'Please enter at least {0} characters.'
- }
- });
Now you can use the minLength validtype to define an input box that should be inputed at least 5 characters:
- <input class="easyui-validatebox" validType="minLength[5]">
Properties
Name | Type | Description | Default |
required | boolean | Defines if the field should be inputed. | false |
validType | string | Defines the field valid type, such as email, url, etc. | null |
missingMessage | string | Tooltip text that appears when the text box is empty. | This field is required. |
invalidMessage | string | Tooltip text that appears when the content of text box is invalid. | null |
Methods
Name | Parameter | Description |
destroy | none | Remove and destroy the component. |
validate | none | Do the validation to determine whether the content of text box is valid. |
isValid | none | call validate method and return the validation result, true or false. |
Combo
Extend from $.fn.validatebox.defaults. Override defaults with $.fn.combo.defaults.
Dependencies
- validatebox
- panel
Usage
- <input id="cc" value="001">
- <select id="cc"></select>
- $('#cc').combo({
- required:true,
- multiple:true
- });
Properties
The properties extend from validatebox, below is the added properties for combo.
Name | Type | Description | Default | |
width | number | The width of the component. | auto | |
panelWidth | number | The drop down panel width. | null | |
panelHeight | number | The drop down panel height. | 200 | |
multiple | boolean | Defines if support multiple selection. | false | |
separator | string | The separator char for text when multiple selection. | , | |
editable | boolean | Defines if user can type text directly into the field. | true | |
disabled | boolean | Defines if to disable the field. | false | |
hasDownArrow | boolean | Defines if to display the down arrow button. | true | |
value | string | The default value. | ||
delay | number | Delay to do searching from the last key input event. | 200 | |
keyHandler | object | A function called when user press key. The default keyHandler is defined as: keyHandler: { up: function(){}, down: function(){}, enter: function(){}, query: function(q){} } |
Events
Name | Parameters | Description |
onShowPanel | none | Fires when drop down panel show. |
onHidePanel | none | Fires when drop down panel hide. |
onChange | newValue, oldValue | Fires when the field value is changed. |
Methods
The methods extend from validatebox, below is the added methods for combo.
Name | Parameter | Description |
options | none | Return the options object. |
panel | none | Return the drop down panel object. |
textbox | none | Retun the textbox object. |
destroy | none | Destroy the component. |
resize | width | Resize the component width. |
showPanel | none | Show the drop down panel. |
hidePanel | none | Hide the drop down panel. |
disable | none | Disable the component. |
enable | none | Enable the component. |
validate | none | Validate the input value. |
isValid | none | Return the validate result. |
clear | none | Clear the component value. |
getText | none | Get the input text. |
setText | text | Set the text value. |
getValues | none | Get the component value array. |
setValues | values | Set the component value array. |
getValue | none | Get the component value. |
setValue | value | Set the component value. |
ComboBox
Extend from $.fn.combo.defaults. Override defaults with $.fn.combobox.defaults.
Dependencies
- combo
Usage
- $('#cc').combobox({
- url:'combobox_data.json',
- valueField:'id',
- textField:'text'
- });
The json data format sample:
- [{
- "id":1,
- "text":"text1"
- },{
- "id":2,
- "text":"text2"
- },{
- "id":3,
- "text":"text3",
- "selected":true
- },{
- "id":4,
- "text":"text4"
- },{
- "id":5,
- "text":"text5"
- }]
Properties
The properties extend from combo, below is the added properties for combobox.
Name | Type | Description | Default |
valueField | string | The underlying data value name to bind to this ComboBox. | value |
textField | string | The underlying data field name to bind to this ComboBox. | text |
mode | string | Defines how to load list data when text changed. Set to 'remote' if the combobox loads from server. | local |
url | string | A URL to load list data from remote. | null |
method | string | The http method to retrieve data. | post |
data | array | The list data to be loaded. | null |
filter | function | Defines how to filter the local data when 'mode' setted to 'local'. The function takes two parameters: | |
formatter | function | Defineds how to render the row. The function takes one parameter: row. |
Events
The events extend from combo, below is the added events for combobox.
Name | Parameters | Description |
onLoadSuccess | none | Fires when remote data is loaded successfully. |
onLoadError | none | Fires when remote data load error. |
onSelect | record | Fires when user select a list item. |
onUnselect | record | Fires when user unselect a list item. |
Methods
The methods extend from combo, below is the added or overridden methods for combobox.
Name | Parameter | Description |
options | none | Return the options object. |
getData | none | Return the loaded data. |
loadData | data | Load the locale list data. |
reload | url | Request the remote list data. |
setValues | values | Set the combobox value array. |
setValue | value | Set the combobox value. |
clear | none | Clear the combobox value. |
select | value | Select the specified item. |
unselect | value | Unselect the specified item. |
ComboTree
Extend from $.fn.combo.defaults and $.fn.tree.defaults. Override defaults with $.fn.combotree.defaults.
Dependencies
- combo
- tree
Usage
- <select id="cc" style="width:200px;"></select>
- <input id="cc" value="01">
- $('#cc').combotree({
- url:'tree_data.json'
- });
Properties
The properties extend from combo and tree, below is the overridden properties for combotree.
Name | Type | Description | Default |
editable | boolean | Defines if user can type text directly into the field. | false |
Events
The events extend from combo and tree.
Methods
The methods extend from combo, below is the added and overridden methods for combotree.
Name | Parameter | Description |
options | none | Return the options object. |
tree | none | Return the tree object. |
loadData | data | Load the locale tree data. |
reload | url | Request the remote tree data again. |
clear | none | Clear the component value. |
setValues | values | Set the component value array. |
setValue | value | Set the component value. |
ComboGrid
Extend from $.fn.combo.defaults and $.fn.datagrid.defaults. Override defaults with $.fn.combogrid.defaults.
Dependencies
- combo
- datagrid
Usage
- <select id="cc" name="dept" style="width:250px;"></select>
- <input id="cc" name="dept" value="01">
- $('#cc').combogrid({
- panelWidth:450,
- value:'006',
- idField:'code',
- textField:'name',
- url:'datagrid_data.json',
- columns:[[
- {field:'code',title:'Code',width:60},
- {field:'name',title:'Name',width:100},
- {field:'addr',title:'Address',width:120},
- {field:'col4',title:'Col41',width:100}
- ]]
- });
Properties
The properties extend from combo and datagrid, below is the added properties for combogrid.
Name | Type | Description | Default |
loadMsg | string | The message displayed when datagrid load remote data. | null |
idField | string | The id field name. | null |
textField | string | The text field to be displayed in textbox. | null |
mode | string | Defines how to load datagrid data when text changed. Set to 'remote' if the combogrid loads from server. | local |
filter | function(q, row) | Defines how to select the local data when 'mode' setted to 'local'. Return true to select the row. |
Events
The events extend from combo and datagrid.
Methods
The methods extend from combo, below is the added or overriden methods for combogrid.
Name | Parameter | Description |
options | none | Return the options object. |
grid | none | Return the datagrid object. |
setValues | values | Set the component value array. |
setValue | value | Set the component value. |
clear | none | Clear the component value. |
NumberBox
Extend from $.fn.validatebox.defaults. Override defaults with $.fn.numberbox.defaults.
Dependencies
- validatebox
Usage
- <input type="text" id="nn"></input>
- $('#nn').numberbox({
- min:0,
- precision:2
- });
Properties
The properties extend from validatebox, below is the added properties for numberbox.
Name | Type | Description | Default |
disabled | boolean | Defines if to disable the field. | false |
min | number | The minimum allowed value. | null |
max | number | The maximum allowed value. | null |
precision | number | The maximum precision to display after the decimal separator. | 0 |
Methods
The methods extend from validatebox, below is the added or overridden methods for numberbox.
Name | Parameter | Description |
disable | none | Disable the field. |
enable | none | Enable the field. |
fix | none | Fix the value to valid value. |
DateBox
Extend from $.fn.combo.defaults. Override defaults with $.fn.datebox.defaults
Dependencies
- combo
- calendar
Usage
- <input id="dd" type="text"></input>
- $('#dd').datebox({
- required:true
- });
Properties
The properties extend from combo, below is the added properties for datebox.
Name | Type | Description | Default |
panelWidth | number | The drop down calendar panel width. | 180 |
panelHeight | number | The drop down calendar panel height. | auto |
currentText | string | The text to display for the current day button. | Today |
closeText | string | The text to display for the close button. | Close |
okText | string | The text to display for the ok button. | Ok |
disabled | boolean | When true to disable the field. | false |
formatter | function | A function to format the date, the function take a 'date' parameter and return a string value. | |
parser | function | A function to parse a date string, the function take a 'date' string and return a date value. |
Events
Name | Parameters | Description |
onSelect | date | Fires when user select a date. |
Methods
The methods extend from combo, below is the overridden methods for datebox.
Name | Parameter | Description |
options | none | Return the options object. |
calendar | none | Get the calendar object. |
setValue | value | Set the datebox value. |
DateTimeBox
Extend from $.fn.datebox.defaults, Override defaults with $.fn.datetimebox.defaults.
Dependencies
- datebox
- timespinner
Usage
- <input id="dt" type="text"></input>
- $('#dt').datetimebox({
- showSeconds:false
- });
Properties
The properties extend from datebox, below is the added properties for datetimebox:
Name | Type | Description | Default |
showSeconds | boolean | Defines if to display the second information. | true |
Methods
The methods extend from datebox, below is the overridden methods for datetimebox.
Name | Parameter | Description |
options | none | Return the options object. |
spinner | none | Return the timespinner object. |
setValue | value | Set the datetimebox value. |
Calendar
Override defaults with $.fn.calendar.defaults.
Usage
- <div id="cc" style="width:180px;height:180px;"></div>
- $('#cc').calendar({
- width:600,
- height:600,
- current:new Date()
- });
Properties
Name | Type | Description | Default |
width | number | The width of calendar component. | 180 |
height | number | The height of calendar component. | 180 |
fit | boolean | When true to set the calendar size fit it's parent container. | false |
border | boolean | Defines if to show the border. | true |
weeks | array | The list of week to be showed. | ['S','M','T','W','T','F','S'] |
months | array | The list of month to be showed. | ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] |
year | number | The year of calendar. | current year(four digits) |
month | number | The month of calendar. | current month, start with 1 |
current | Date | The current date. | current date |
Events
Name | Parameters | Description |
onSelect | date | Fires when user select a date. |
Methods
Name | Parameter | Description |
options | none | Return the options object. |
resize | none | Resize the calendar size. |
moveTo | date | Move the calendar to specified date. |
Spinner
Extend from $.fn.validatebox.defaults. Override defaults with $.fn.spinner.defaults.
Dependencies
- validatebox
Usage
- <input id="ss" value="2">
Properties
The properties extend from validatebox, below is the added properties for spinner.
Name | Type | Description | Default |
width | number | The width of this component. | auto |
value | string | The initialize value. | |
min | string | The minimum allowed value. | null |
max | string | The maximum allowed value. | null |
increment | number | The increment value when click spinner button. | 1 |
editable | boolean | Defines if user can type value directly into the field. | true |
disabled | boolean | Defines if to disable the field. | false |
spin | function(down) | A function called when user click the spinner button. |
Events
Name | Parameters | Description |
onSpinUp | none | Fires when user click the up spinner button. |
onSpinDown | none | Fires when user click the down spinner button. |
Methods
The methods extend from validatebox, below is the added methods for spinner.
Name | Parameter | Description |
options | none | Return the options object. |
destroy | none | Destroy the spinner component. |
resize | width | Reset the component width. |
enable | none | Enable the component. |
disable | none | Disable the component. |
getValue | none | Get the component value. |
setValue | value | Set the component value. |
clear | none | Clear the component value. |
NumberSpinner
Extend from $.fn.spinner.defaults and $.fn.numberbox.defaults. Override defaults with $.fn.numberspinner.defaults.
Dependencies
- spinner
- numberbox
Usage
- <input id="ss" min="10" max="100" required="true" style="width:80px;">
Properties
The properties extend from spinner and numberbox.
Events
The events extend from spinner.
Methods
The methods extend from spinner, below is the overridden methods for numberspinner.
Name | Parameter | Description |
options | none | Return the options object. |
setValue | value | Set the numberspinner value. |
Window
Window
Extend from $.fn.panel.defaults. Override defaults with $.fn.window.defaults.
Dependencies
- draggable
- resizable
- panel
Usage
- <div id="win" iconCls="icon-save" title="My Window">
- Window Content
- </div>
- $('#win').window({
- width:600,
- height:400,
- modal:true
- });
- $('#win').window('close'); // close window
Properties
The properties extend from panel, below is the overridden and added properties for window.
Name | Type | Description | Default |
title | string | The window title text. | New Window |
collapsible | boolean | Defines if to show collapsible button. | true |
minimizable | boolean | Defines if to show minimizable button. | true |
maximizable | boolean | Defines if to show maximizable button. | true |
closable | boolean | Defines if to show closable button. | true |
closed | boolean | Defined if to close the window. | false |
zIndex | number | Window z-index,increase from it. | 9000 |
draggable | boolean | Defines if window can be dragged. | true |
resizable | boolean | Defines if window can be resized. | true |
shadow | boolean | If set to true,when window show the shadow will show also. | true |
inline | boolean | Defines how to stay the window, true to stay inside its parent, false to go on top of all elements. | false |
modal | boolean | Defines if window is a modal window. | true |
Events
The events extend from panel.
Methods
The methods extend from panel, below is the added methods for window.
Name | Parameter | Description |
window | none | Return the window object. |
Dialog
Extend from $.fn.window.defaults. Override defaults with $.fn.dialog.defaults.
Dependencies
- window
- linkbutton
Usage
- <div id="dd" title="My Dialog" style="width:400px;height:200px;">
- Dialog Content.
- </div>
- $('#dd').dialog({
- modal:true
- });
Properties
The properties extend from window, below is the overridden properties for dialog.
Name | Type | Description | Default |
title | string | The dialog title text. | New Dialog |
collapsible | boolean | Defines if to show collapsible button. | false |
minimizable | boolean | Defines if to show minimizable button. | false |
maximizable | boolean | Defines if to show maximizable button. | false |
resizable | boolean | Defined if the dialog can be resized. | false |
toolbar | array | The top toolbar of dialog, each tool options is same as linkbutton. | null |
buttons | array | The bottom buttons of dialog, each button options is same as linkbutton. | null |
Events
The events extend from window.
Methods
The methods extend from window, below is the added methods for dialog.
Name | Parameter | Description |
dialog | none | Return the dialog object. |
Messager
Override defaults with $.messager.defaults.
Dependencies
- window
- linkbutton
- progressbar
Usage
- $.messager.alert('Warning','The warning message');
- $.messager.confirm('Confirm','Are you sure you want to delete record?',function(r){
- if (r){
- alert('ok');
- }
- });
Properties
Name | Type | Description | Default |
ok | string | The Ok button text. | Ok |
cancel | string | The Cancel button text. | Cancel |
Methods
Name | Parameters | Description |
$.messager.show | options | Show a message window on right bottom of screen. The options parameter is a configuration object: |
$.messager.alert | title, msg, icon, fn | Show an alert window. Parameters: |
$.messager.confirm | title, msg, fn | Show a confirmation message window with Ok and Cancel buttons. Parameters: |
$.messager.prompt | title, msg, fn | Show a message window with Ok and Cancel buttons prompting user to enter some text. Parameters: |
$.messager.progress | options or method | Show a progress message window. Code Example Show progress message window. $.messager.progress(); Now close the message window. $.messager.progress('close'); |
DataGrid and Tree
DataGrid
Extend from $.fn.panel.defaults. Override defaults with $.fn.datagrid.defaults.
Dependencies
- panel
- resizable
- linkbutton
- pagination
Usage
- <table id="tt"></table>
- $('#tt').datagrid({
- url:'datagrid_data.json',
- columns:[[
- {field:'code',title:'Code',width:100},
- {field:'name',title:'Name',width:100},
- {field:'price',title:'Price',width:100,align:'right'}
- ]]
- });
DataGrid Properties
The properties extend from panel. below is the added properties for datagrid.
Name | Type | Description | Default |
columns | array | The datagrid columns config object, see column properties for more details. | null |
frozenColumns | array | Same as the columns property, but the these columns will be frozen on left. | null |
fitColumns | boolean | True to auto expand/contract the size of the columns to fit the grid width and prevent horizontal scrolling. | false |
striped | boolean | True to stripe the rows. | false |
method | string | The method type to request remote data. | post |
nowrap | boolean | True to display data in one line. | true |
idField | string | Indicate which field is an identity field. | null |
url | string | A URL to request data from remote site. | null |
loadMsg | string | When loading data from remote site, show a prompt message. | Processing, please wait … |
pagination | boolean | True to show a pagination toolbar on datagrid bottom. | false |
rownumbers | boolean | True to show a row number column. | false |
singleSelect | boolean | True to allow selecting only one row. | false |
pageNumber | number | When set pagination property, initialize the page number. | 1 |
pageSize | number | When set pagination property, initialize the page size. | 10 |
pageList | array | When set pagination property, initialize the page size selecting list. | [10,20,30,40,50] |
queryParams | object | When request remote data, sending additional parameters also. | {} |
sortName | string | Defines which column can be sorted. | null |
sortOrder | string | Defines the column sort order, can only be 'asc' or 'desc'. | asc |
remoteSort | boolean | Defines if to sort data from server. | true |
showFooter | boolean | Defines if to show row footer. | false |
rowStyler | function | Return style such as 'background:red'. The function take two parameter: | |
loadFilter | function | Return the filtered data to display. The function take one parameter 'data' that indicate the original data. You can change original source data to standard data format. This function must return standard data object that contain 'total' and 'rows' properties. | |
editors | object | Defines the editor when editing a row. | predefined editors |
view | object | Defines the view of datagrid. | default view |
Column Properties
The DataGrid Columns is an array object, which element is an array too. The element of element array is a config object, which defines every column field.
code example:
- columns:[[
- {field:'itemid',title:'Item ID',rowspan:2,width:80,sortable:true},
- {field:'productid',title:'Product ID',rowspan:2,width:80,sortable:true},
- {title:'Item Details',colspan:4}
- ],[
- {field:'listprice',title:'List Price',width:80,align:'right',sortable:true},
- {field:'unitcost',title:'Unit Cost',width:80,align:'right',sortable:true},
- {field:'attr1',title:'Attribute',width:100},
- {field:'status',title:'Status',width:60}
- ]]
Name | Type | Description | Default |
title | string | The column title text. | undefined |
field | string | The column field name. | undefined |
width | number | The width of column. | undefined |
rowspan | number | Indicate how many rows a cell should take up. | undefined |
colspan | number | Indicate how many columns a cell should take up. | undefined |
align | string | Indicate how to align the column data. 'left','right','center' can be used. | undefined |
sortable | boolean | True to allow the column can be sorted. | undefined |
resizable | boolean | True to allow the column can be resized. | undefined |
hidden | boolean | True to hide the column. | undefined |
checkbox | boolean | True to show a checkbox. | undefined |
formatter | function | The cell formatter function, take three parameter: | undefined |
styler | function | The cell styler function, return style string to custom the cell style such as 'background:red'. The function take three parameter: | undefined |
sorter | function | The custom field sort function, take two parameters: | undefined |
editor | string,object | Indicate the edit type. When string indicates the edit type, when object contains two properties: | undefined |
Editor
Override defaults with $.fn.datagrid.defaults.editors.
Every editor has following actions:
Name | Parameters | Description |
init | container, options | Initialize the editor and return the target object. |
destroy | target | Destroy the editor if necessary. |
getValue | target | Get value from editor text. |
setValue | target , value | Set value for editor. |
resize | target , width | Resize the editor if necessary. |
For example, the text editor is defined as following:
- $.extend($.fn.datagrid.defaults.editors, {
- text: {
- init: function(container, options){
- var input = $('<input type="text" class="datagrid-editable-input">').appendTo(container);
- return input;
- },
- getValue: function(target){
- return $(target).val();
- },
- setValue: function(target, value){
- $(target).val(value);
- },
- resize: function(target, width){
- var input = $(target);
- if ($.boxModel == true){
- input.width(width - (input.outerWidth() - input.width()));
- } else {
- input.width(width);
- }
- }
- }
- });
DataGrid View
Override defaults with $.fn.datagrid.defaults.view.
The view is an object that will tell datagrid how to render rows. The object must defines the following functions:
Name | Parameters | Description |
render | target, container, frozen | Called when the data is loaded. |
renderFooter | target, container, frozen | This is an option function to render row footer. |
renderRow | target, fields, frozen, rowIndex, rowData | This is an option function and will be called by render function. |
refreshRow | target, rowIndex | Defines how to refresh the specified row. |
onBeforeRender | target, rows | Fires before the view is rendered. |
onAfterRender | target | Fires after the view is rendered. |
Events
The events extend from panel, below is the added events for datagrid.
Name | Parameters | Description |
onLoadSuccess | data | Fires when data is loaded successfully. |
onLoadError | none | Fires when some error occur to load remote data. |
onBeforeLoad | param | Fires before a request is made to load data. If return false the load action will be canceled. |
onClickRow | rowIndex, rowData | Fires when user click a row, the parameters contains: |
onDblClickRow | rowIndex, rowData | Fires when user dblclick a row, the parameters contains: |
onClickCell | rowIndex, field, value | Fires when user click a cell. |
onDblClickCell | rowIndex, field, value | Fires when user dblclick a cell. |
onSortColumn | sort, order | Fires when user sort a column, the parameters contains: |
onResizeColumn | field, width | Fires when user resize the column. |
onSelect | rowIndex, rowData | Fires when user select a row, the parameters contains: |
onUnselect | rowIndex, rowData | Fires when user unselect a row, the parameters contains: |
onSelectAll | rows | Fires when user select all rows. |
onUnselectAll | rows | Fires when user unselect all rows. |
onBeforeEdit | rowIndex, rowData | Fires when user start editing a row, the parameters contains: |
onAfterEdit | rowIndex, rowData, changes | Fires when user finish editing, the parameters contains: |
onCancelEdit | rowIndex, rowData | Fires when user cancel editing a row, the parameters contains: |
onHeaderContextMenu | e, field | Fires when the header of datagrid is right clicked. |
onRowContextMenu | e, rowIndex, rowData | Fires when a row is right clicked. |
Methods
Name | Parameter | Description |
options | none | Return the options object. |
getPager | none | Return the pager object. |
getPanel | none | Return the panel object. |
getColumnFields | frozen | Return the column fields. If frozen setted to true the frozen column fields is returned. |
getColumnOption | field | Return the specified column option. |
resize | param | Do resize and do layout. |
load | param | Load and show the first page rows. If the 'param' is specified, it will replace with the queryParams property. |
reload | param | Reload the rows. Same as the 'load' method but stay on current page. |
reloadFooter | footer | Reload the footer rows. |
loading | none | Display loading status. |
loaded | none | Hide loading status. |
fitColumns | none | Make columns auto expand/collapse to fit datagrid width. |
fixColumnSize | none | fix columns size. |
fixRowHeight | index | fix the specified row height. |
loadData | data | Load local data, the old rows will be removed. |
getData | none | Return the loaded data. |
getRows | none | Return the current page rows. |
getFooterRows | none | Return the footer rows. |
getRowIndex | row | Return the specified row index, the row parameter can be a row record or an id field value. |
getSelected | none | Return the first selected row record or null. |
getSelections | none | Return all selected rows, when no record selected, am empty array will return. |
clearSelections | none | Clear all selections. |
selectAll | none | Select all current page rows. |
unselectAll | none | Unselect all current page rows. |
selectRow | index | Select a row, the row index start with 0. |
selectRecord | idValue | Select a row by passing id value parameter. |
unselectRow | index | Unselect a row. |
beginEdit | index | Begin editing a row. |
endEdit | index | End editing a row. |
cancelEdit | index | Cancel editing a row. |
getEditors | index | Get the specified row editors. Each editor has the following properties: |
getEditor | options | Get the specified editor, the options contains two properties: |
refreshRow | index | Refresh a row. |
validateRow | index | validate the specified row, return true when valid. |
updateRow | param | Update the specified row, the param contains following properties: |
appendRow | row | Append a new row. |
insertRow | param | Insert a new row, the param contains following properties: |
deleteRow | index | Delete a row. |
getChanges | type | Get changed rows since the last commit. The type parameter indicate which type changed rows, possible value is: inserted,deleted,updated,etc. When the type parameter is not assigned, return all changed rows. |
acceptChanges | none | Commits all the changes data since it was loaded or since the last time acceptChanges was called. |
rejectChanges | none | Rolls back all the changes data since it was created, or since the last time acceptChanges was called. |
mergeCells | options | Merge some cells to one cell, the options contains following properties: |
showColumn | field | Display the specified column. |
hideColumn | field | Hide the specified column. |
PropertyGrid
Extend from $.fn.datagrid.defaults. Override defaults with $.fn.propertygrid.defaults.
Dependencies
- datagrid
Usage
- <table id="pg"></table>
- $('#pg').propertygrid({
- url:'propertygrid_data.json',
- showGroup:true
- });
Properties
The properties extend from datagrid, below is the added properties for propertygrid.
Name | Type | Description | Default |
showGroup | boolean | Defines if to show property group. | false |
groupField | string | Defines the group field name. | group |
groupFormatter | function | Defines how to format the group value. |
Tree
Override defaults with $.fn.tree.defaults.
Dependencies
- draggable
- droppable
Usage
Tree can be definded in <ul> element. The markup can defines leaf and children, below is an example:
- <ul id="tt">
- <li>
- <span>Folder</span>
- <ul>
- <li>
- <span>Sub Folder 1</span>
- <ul>
- <li>
- <span><a href="#">File 11</a></span>
- </li>
- <li>
- <span>File 12</span>
- </li>
- <li>
- <span>File 13</span>
- </li>
- </ul>
- </li>
- <li>
- <span>File 2</span>
- </li>
- <li>
- <span>File 3</span>
- </li>
- </ul>
- </li>
- <li>
- <span>File21</span>
- </li>
- </ul>
Tree can also be defined in an empty <ul> element:
- <ul id="tt"></ul>
- $('#tt').tree({
- url:'tree_data.json'
- });
Tree data format
Every node can contains following properties:
- id: node id, which is important to load remote data
- text: node text to show
- state: node state, 'open' or 'closed', default is 'open'. When set to 'closed', the node have children nodes and will load them from remote site
- checked: Indicate whether the node is checked selected.
- attributes: custom attributes can be added to a node
- children: an array nodes defines some children nodes
Some example:
- [{
- "id":1,
- "text":"Folder1",
- "iconCls":"icon-save",
- "children":[{
- "text":"File1",
- "checked":true
- },{
- "text":"Books",
- "state":"open",
- "attributes":{
- "url":"/demo/book/abc",
- "price":100
- },
- "children":[{
- "text":"PhotoShop",
- "checked":true
- },{
- "id": 8,
- "text":"Sub Bookds",
- "state":"closed"
- }]
- }]
- },{
- "text":"Languages",
- "state":"closed",
- "children":[{
- "text":"Java"
- },{
- "text":"C#"
- }]
- }]
Properties
Name | Type | Description | Default |
url | string | a URL to retrieve remote data. | null |
method | string | The http method to retrieve data. | post |
animate | boolean | Defines if to show animation effect when node expand or collapse. | false |
checkbox | boolean | Defines if to show the checkbox before every node. | false |
cascadeCheck | boolean | Defines if to cascade check. | true |
onlyLeafCheck | boolean | Defines if to show the checkbox only before leaf node. | false |
dnd | boolean | Defines if to enable drag and drop. | false |
data | array | The node data to be loaded. | null |
Events
Many events callback function can take the 'node' parameter, which contains following properties:
- id: An identity value bind to the node.
- text: Text to be showed.
- checked: Whether the node is checked.
- attributes: Custom attributes bind to the node.
- target: Target DOM object.
Name | Parameters | Description |
onClick | node | Fires when user click a node, the node parameter contains following properties: |
onDblClick | node | Fires when user dblclick a node. |
onBeforeLoad | node, param | Fires before a request is made to load data, return false to cancel this load action. |
onLoadSuccess | node, data | Fires when data loaded successfully. |
onLoadError | arguments | Fires when data loaded fail, the arguments parameter is same as the 'error' function of jQuery.ajax. |
onBeforeExpand | node | Fires before node is expanded, return false to cancel this expand action. |
onExpand | node | Fires when node is expanded. |
onBeforeCollapse | node | Fires before node is collapsed, return false to cancel this collapse action. |
onCollapse | node | Fires when node is collapsed. |
onCheck | node, checked | Fires when users click the checkbox. |
onBeforeSelect | node | Fires before node is selected, return false to cancel this select action. |
onSelect | node | Fires when node is selected. |
onContextMenu | e, node | Fires when node is right clicked. |
onDrop | target, source, point | Fires when a node is dropped. |
onBeforeEdit | node | Fires before edit node. |
onAfterEdit | node | Fires after edit node. |
onCancelEdit | node | Fires when cancel the editing action. |
Methods
Name | Parameter | Description |
options | none | Return the options of tree. |
loadData | data | Load the tree data. |
getNode | target | get the specified node object. |
getData | target | get the specified node data, including its children. |
reload | target | Reload tree data. |
getRoot | none | Get the root node, return node object |
getRoots | none | Get the root nodes, return node array. |
getParent | target | Get the parent node, the target parameter indicate the node DOM object. |
getChildren | target | Get the children nodes, the target parameter indicate the node DOM object. |
getChecked | none | Get all checked nodes. |
getSelected | none | Get the selected node and return it, if no node selected return null. |
isLeaf | target | Determine the specified node is leaf, the target parameter indicate the node DOM object. |
find | id | Find the specifed node and return the node object. |
select | target | Select a node, the target parameter indicate the node DOM object. |
check | target | Set the specified node to checked. |
uncheck | target | Set the specified node to unchecked. |
collapse | target | Collapse a node, the target parameter indicate the node DOM object. |
expand | target | Expand a node, the target parameter indicate the node DOM object. |
collapseAll | target | Collapse all nodes. |
expandAll | target | Expand all nodes. |
expandTo | target | Expand from root to specified node. |
append | param | Append some children nodes to a parent node. param parameter has two properties: |
toggle | target | Toggles expanded/collapsed state of the node, the target parameter indicate the node DOM object. |
insert | param | Insert a node to before or after specified node. the 'param' parameter contains following properties: |
remove | target | Remove a node and it's children nodes, the target parameter indicate the node DOM object. |
pop | target | Pop a node and it's children nodes, the method is same as remove but return the removed node data. |
update | param | Update the specified node. param has following properties: |
enableDnd | none | Enable drag and drop feature. |
disableDnd | none | Disable drag and drop feature. |
beginEdit | nodeEl | Begin editing a node. |
endEdit | nodeEl | End editing a node. |
cancelEdit | nodeEl | Cancel editing a node. |
TreeGrid
Extend from $.fn.datagrid.defaults. Override defaults with $.fn.treegrid.defaults.
Dependencies
- datagrid
Usage
- <table id="tt"></table>
- $('#tt').treegrid({
- url:'treegrid_data.json',
- treeField:'name',
- columns:[[
- {title:'Task Name',field:'name',width:180},
- {field:'persons',title:'Persons',width:60,align:'right'},
- {field:'begin',title:'Begin Date',width:80},
- {field:'end',title:'End Date',width:80}
- ]]
- });
Properties
The properties extend from datagrid, below is the added properties for treegrid.
Name | Type | Description | Default |
treeField | string | Defines the tree node field. | null |
animate | boolean | Defines if to show animation effect when node expand or collapse. | false |
Events
The events extend from datagrid, below is the added events for treegrid.
Name | Parameters | Description |
onClickRow | row | Fires when user click a node. |
onDblClickRow | row | Fires when user dblclick a node. |
onBeforeLoad | row, param | Fires before a request is made to load data, return false to cancel this load action. |
onLoadSuccess | row, data | Fires when data loaded successfully. |
onLoadError | arguments | Fires when data loaded fail, the arguments parameter is same as the 'error' function of jQuery.ajax. |
onBeforeExpand | row | Fires before node is expanded, return false to cancel this expand action. |
onExpand | row | Fires when node is expanded. |
onBeforeCollapse | row | Fires before node is collapsed, return false to cancel this collapse action. |
onCollapse | row | Fires when node is collapsed. |
onContextMenu | e, row | Fires when node is right clicked. |
onBeforeEdit | row | Fires when user start editing a node. |
onAfterEdit | row,changes | Fires when user finish editing. |
onCancelEdit | row | Fires when user cancel editing a node. |
Methods
Name | Parameter | Description |
options | none | Return the options of treegrid. |
resize | options | Set treegrid size, the options contains two properties: |
fixRowHeight | id | fix the specified row height. |
loadData | data | Load the treegrid data. |
reload | id | Reload treegrid data. |
reloadFooter | footer | Reload footer data. |
getData | none | Get the loaded data. |
getFooterRows | none | Get the footer data. |
getRoot | none | Get the root node, return node object |
getRoots | none | Get the root nodes, return node array. |
getParent | id | Get the parent node. |
getChildren | id | Get the children nodes. |
getSelected | none | Get the selected node and return it, if no node selected return null. |
getSelections | none | Get all selected nodes. |
getLevel | id | Get the specified node level. |
find | id | Find the specifed node and return the node data. |
select | id | Select a node. |
unselect | id | Unselect a node. |
selectAll | none | Select all nodes. |
unselectAll | none | Unselect all nodes. |
collapse | id | Collapse a node. |
expand | id | Expand a node. |
collapseAll | id | Collapse all nodes. |
expandAll | id | Expand all nodes. |
expandTo | id | Expand from root to specified node. |
toggle | id | Toggles expanded/collapsed state of the node. |
append | param | Append nodes to a parent node. The 'param' parameter contains following properties: |
remove | id | Remove a node and it's children nodes. |
refresh | id | Refresh the specified node. |
beginEdit | id | Begin editing a node. |
endEdit | id | End editing a node. |
cancelEdit | id | Cancel editing a node. |
getEditors | id | Get the specified row editors. Each editor has the following properties: |
getEditor | options | Get the specified editor, the options contains two properties: |