May 09, 2021 jQuery EasyUI
jQuery EasyUI provides a complete collection of components for creating cross-browser web pages, including powerful datagrids (data grids), treegrids (tree tables), panels (panels), combo (pull-down combinations), and more, which can be combined or used separately.
Each component of easyui has properties, methods, and events. Users can easily extend these components.
The property is defined at jQuery.fn. { plugin}.defaults。 For example, dialog's properties are defined on jQuery.fn.dialog.defaults.
Events (callback functions) are also defined at jQuery.fn. {plugin}.defaults。
The syntax of the calling method: $('selector') .plugin ('method', parameter);
Among them:
The method is defined at jQuery.fn. { plugin}.methods。 E ach method has two parameters: jq and param. T he first argument 'jq' is required to refer to the jQuery object. T he second parameter 'param' refers to the actual parameters passed by the method. For example, the method to extend the dialog component is called 'mymove', and the code is as follows:
$.extend($.fn.dialog.methods, {
mymove: function(jq, newposition){
return jq.each(function(){
$(this).dialog('move', newposition);
});
}
});
Now you can call the 'mymove' method to move the dialog to the specified location:
$('#dd').dialog('mymove', {
left: 200,
top: 100
});
Download the library and reference EasyUI CSS and JavaScript files on your page.
<link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
<script type="text/javascript" src="easyui/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
Once you reference the necessary files for EasyUI, you can define an EasyUI component by tagging or using JavaScript. For example, to top a panel with collapsible functionality, you need to write the following HTML code:
<div id="p" class="easyui-panel" style="width:500px;height:200px;padding:10px;"
title="My Panel" iconCls="icon-save" collapsible="true">
The panel content
</div>
When creating components by tagging, the 'data-options' property is used to support HTML5-compatible property names since version 1.3. So you can rewrite the code above as follows:
<div id="p" class="easyui-panel" style="width:500px;height:200px;padding:10px;"
title="My Panel" data-options="iconCls:'icon-save',collapsible:true">
The panel content
</div>
The following code shows how to create a combo box that binds to the 'onSelect' event.
<input class="easyui-combobox" name="language"
data-options="
url:'combobox_data.json',
valueField:'id',
textField:'text',
panelHeight:'auto',
onSelect:function(record){
alert(record.text)
}">