Latest web development tutorials
×

jQuery EasyUI Tutorial

jQuery EasyUI Tutorial jQuery EasyUI Introduction

jEasyUI application

jEasyUI Create a CRUD application jEasyUI Create a CRUD data grid jEasyUI Form CRUD application jEasyUI Create an RSS reader

jEasyUI Drag and drop

jEasyUI Basic drag and drop jEasyUI Create a drag-and-drop shopping cart jEasyUI Create a school curriculum

jEasyUI Menus and buttons

jEasyUI Create a simple menu jEasyUI Create a link button jEasyUI Create a menu button jEasyUI Create a split button

jEasyUI layout

jEasyUI Create a border layout jEasyUI Create a complex layout jEasyUI Creates a fold panel jEasyUI Create a tab page jEasyUI Dynamically add a tab jEasyUI Add the AutoPlay tab jEasyUI Create the XP style left panel

jEasyUI Data grid

jEasyUI Convert HTML tables to data grids jEasyUI Get the selected row data jEasyUI Add the query function jEasyUI Add a toolbar jEasyUI Create complex toolbars jEasyUI Sets the frozen column jEasyUI Dynamically change columns jEasyUI Format the column jEasyUI Set sort jEasyUI Custom sorting jEasyUI Create a column combination jEasyUI Add a check box jEasyUI Custom tab jEasyUI Enable in-line editing jEasyUI Extension editor jEasyUI Column operation jEasyUI Merge Cells jEasyUI Create a custom view jEasyUI Create a footer summary jEasyUI Condition Sets the line background color jEasyUI Create an attribute grid jEasyUI The extended line shows the details jEasyUI Create a subgrid jEasyUI Display massive data jEasyUI Add a paging component

jEasyUI window

jEasyUI Create a simple window jEasyUI Customize the Window Toolbar jEasyUI Window and layout jEasyUI Create a dialog box jEasyUI Customize the dialog box

jEasyUI Tree menu

jEasyUI Use the markup to create a tree menu jEasyUI Create an asynchronous tree menu jEasyUI Tree menu to add nodes jEasyUI Create a tree menu with check boxes jEasyUI Tree menu drag and drop control jEasyUI The Tree menu loads the parent / child nodes jEasyUI Create the base tree grid jEasyUI Create a complex tree grid jEasyUI Dynamic loading of tree jEasyUI The tree grid adds pagination jEasyUI Tree-lazy lazy-loading node

jEasyUI Form

jEasyUI Create an asynchronous submission form jEasyUI Form validation jEasyUI Create a tree drop-down box jEasyUI Format the drop-down box jEasyUI Filter down the data grid

jEasyUI Reference Manual

jQuery EasyUI Plugin jQuery EasyUI Extended

jQuery EasyUI form plugin - Combobox combo box

jQuery EasyUI plugin jQuery EasyUI plugin

Extended from $ .fn.combo.defaults. By $ .fn.combobox.defaults override the default defaults.

Combo box (combobox) displays a text box and drop-down lists can be edited, the user can select one or more values ​​from drop-down list. The user can enter text directly into the top of the list, or select one or more existing value from the list.

rely

  • combo

usage

Create a combo box from the <select> element with predefined structure (combobox).

<Select id = "cc" class = "easyui-combobox" name = "dept" style = "width: 200px;">
    <Option value = "aa"> aitem1 </ option>
    <Option> bitem2 </ option>
    <Option> bitem3 </ option>
    <Option> ditem4 </ option>
    <Option> eitem5 </ option>
</ Select>

From the <input> tags create a combo box (combobox).

<Input id = "cc" class = "easyui-combobox" name = "dept"
    data-options = "valueField: 'id', textField: 'text', url: 'get_data.php'">

Use javascript to create a combo box (combobox).

<Input id = "cc" name = "dept" value = "aa">
$ ( '# Cc'). Combobox ({
    url: 'combobox_data.json',
    valueField: 'id',
    textField: 'text'
});

Create two dependent combo boxes (combobox).

<Input id = "cc1" class = "easyui-combobox" data-options = "
    valueField: 'id',
    textField: 'text',
    url: 'get_data1.php',
    onSelect: function (rec) {
    var url = '? get_data2.php id =' + rec.id;
    . $ ( '# Cc2') combobox ( 'reload', url);
    } ">
<Input id = "cc2" class = "easyui-combobox" data-options = "valueField: 'id', textField: 'text'">

json data format examples:

[{
    "Id": 1,
    "Text": "text1"
}, {
    "Id": 2,
    "Text": "text2"
}, {
    "Id": 3,
    "Text": "text3",
    "Selected": true
}, {
    "Id": 4,
    "Text": "text4"
}, {
    "Id": 5,
    "Text": "text5"
}]

Attributes

The property extends from the combination (combo), the following is a combo box (combobox) added property.

名称 类型 描述 默认值
valueField string 绑定到该组合框(ComboBox)的 value 上的基础数据的名称。 value
textField string 绑定到该组合框(ComboBox)的 text 上的基础数据的名称。 text
groupField string 指示要被分组的字段。该属性自版本 1.3.4 起可用。 null
groupFormatter function(group) 返回要显示在分组项目上的分组文本。该属性自版本 1.3.4 起可用。
代码实例:
$('#cc').combobox({
	groupFormatter: function(group){
		return '<span style="color:red">' + group + '</span>';
	}
});
mode string 定义在文本改变时如何加载列表数据。如果组合框(combobox)从服务器加载就设置为 'remote'。当设置为 'remote' 模式时,用户输入的值将会被作为名为 'q' 的 http 请求参数发送到服务器,以获取新的数据。 local
url string 从远程加载列表数据的 URL 。 null
method string 用来检索数据的 http 方法。 post
data array 被加载的列表数据。
代码实例:
<input class="easyui-combobox" data-options="
		valueField: 'label',
		textField: 'value',
		data: [{
			label: 'java',
			value: 'Java'
		},{
			label: 'perl',
			value: 'Perl'
		},{
			label: 'ruby',
			value: 'Ruby'
		}]" />
null
filter function 定义当 'mode' 设置为 'local' 时如何过滤本地数据。该函数有两个参数:
q:用户输入的文本。
row:列表中的行数据。
返回 true 则允许显示该行。

代码实例:
$('#cc').combobox({
	filter: function(q, row){
		var opts = $(this).combobox('options');
		return row[opts.textField].indexOf(q) == 0;
	}
});
formatter function 定义如何呈现行。该函数有一个参数:row。
代码实例:
$('#cc').combobox({
	formatter: function(row){
		var opts = $(this).combobox('options');
		return row[opts.textField];
	}
});
loader function(param,success,error) 定义如何从远程服务器加载数据。返回 false 则取消该动作。该函数有下列参数:
param:要传到远程服务器的参数对象。
success(data):当获取数据成功时将被调用的回调函数。
error():当获取数据失败时将被调用的回调函数。
json loader
loadFilter function(data) 返回要显示的过滤数据。该属性自版本 1.3.3 起可用。

event

The event expanded from a combination (combo), the following is a combo box (combobox) to add an event.

名称 参数 描述
onBeforeLoad param 在请求加载数据之前触发,返回 false 则取消加载动作。
代码实例:
// change the http request parameters before load data from server
$('#cc').combobox({
	onBeforeLoad: function(param){
		param.id = 2;
		param.language = 'js';
	}
});
onLoadSuccess none 当远程数据加载成功时触发。
onLoadError none 当远程数据加载失败时触发。
onSelect record 当用户选择一个列表项时触发。
onUnselect record 当用户取消选择一个列表项时触发。

method

The methods extend from a combination (combo), the following is a combo box (combobox) to add or override methods.

名称 参数 描述
options none 返回选项(options)对象。
getData none 返回加载的数据。
loadData data 加载本地列表数据。
reload url 请求远程的列表数据。传 'url' 参数来重写原始的 URL 值。
代码实例:
$('#cc').combobox('reload');  // reload list data using old URL
$('#cc').combobox('reload','get_data.php');  // reload list data using new URL
setValues values 设置组合框(combobox)值的数组。
代码实例:
$('#cc').combobox('setValues', ['001','002']);
setValue value 设置组合框(combobox)的值。
代码实例:
$('#cc').combobox('setValue', '001');
clear none 清除组合框(combobox)的值。
select value 选择指定的选项。
unselect value 取消选择指定的选项。

jQuery EasyUI plugin jQuery EasyUI plugin