Application (Basic)----Easyui

Source: Internet
Author: User

One.

Two, source code.

<! DOCTYPE html>
<meta charset= "UTF-8" >
<title>basic crud application-jquery Easyui crud demo</title>
<link rel= "stylesheet" type= "Text/css" href= "Http://www.jeasyui.com/easyui/themes/default/easyui.css" >
<link rel= "stylesheet" type= "Text/css" href= "Http://www.jeasyui.com/easyui/themes/icon.css" >
<link rel= "stylesheet" type= "Text/css" href= "Http://www.jeasyui.com/easyui/themes/color.css" >
<link rel= "stylesheet" type= "Text/css" href= "Http://www.jeasyui.com/easyui/demo/demo.css" >
<script type= "Text/javascript" src= "Http://code.jquery.com/jquery-1.6.min.js" ></script>
<script type= "Text/javascript" src= "Http://www.jeasyui.com/easyui/jquery.easyui.min.js" ></script>
<body>
<p>click the buttons on a DataGrid toolbar to do crud actions.</p>

<table id= "DG" title= "My Users" class= "Easyui-datagrid" style= "width:700px;height:250px"
Url= "http://www.jeasyui.com/demo/main/get_users.php"
Toolbar= "#toolbar" pagination= "true"
Rownumbers= "true" fitcolumns= "true" singleselect= "true" >
<thead>
<tr>
<th field= "FirstName" width= ">first name</th>"
<th field= "LastName" width= ">last name</th>"
<th field= "Phone" width= ">Phone</th>"
<th field= "Email" width= ">Email</th>"
</tr>
</thead>
</table>
<div id= "Toolbar" >
<a href= "javascript:void (0)" class= "Easyui-linkbutton" iconcls= "Icon-add" plain= "true" onclick= "NewUser ()" > New user</a>
<a href= "javascript:void (0)" class= "Easyui-linkbutton" iconcls= "Icon-edit" plain= "true" onclick= "EditUser ()" > Edit user</a>
<a href= "javascript:void (0)" class= "Easyui-linkbutton" iconcls= "Icon-remove" plain= "true" onclick= "DestroyUser () ">remove user</a>
</div>

<div id= "Dlg" class= "Easyui-dialog" style= "width:400px;height:280px;padding:10px 20px"
Closed= "true" buttons= "#dlg-buttons" >
<div class= "Ftitle" >user information</div>
<form id= "FM" method= "POST" novalidate>
<div class= "Fitem" >
<label>first name:</label>
<input name= "FirstName" class= "Easyui-textbox" required= "true" >
</div>
<div class= "Fitem" >
<label>last name:</label>
<input name= "LastName" class= "Easyui-textbox" required= "true" >
</div>
<div class= "Fitem" >
<label>Phone:</label>
<input name= "Phone" class= "Easyui-textbox" >
</div>
<div class= "Fitem" >
<label>Email:</label>
<input name= "Email" class= "Easyui-textbox" validtype= "Email" >
</div>
</form>
</div>
<div id= "Dlg-buttons" >
<a href= "javascript:void (0)" class= "Easyui-linkbutton c6" iconcls= "Icon-ok" onclick= "Saveuser ()" style= "width : 90px ">Save</a>
<a href= "javascript:void (0)" class= "Easyui-linkbutton" iconcls= "Icon-cancel" onclick= "javascript:$ (' #dlg '). dialog (' Close ') "style=" width:90px ">Cancel</a>
</div>
<script type= "Text/javascript" >
var URL;
function NewUser () {
$ (' #dlg '). Dialog (' Open '). dialog (' Settitle ', ' New User ');
$ (' #fm '). Form (' clear ');
url = ' http://www.jeasyui.com/demo/main/save_user.php ';
}
function Edituser () {
var row = $ (' #dg '). DataGrid (' getselected ');
if (row) {
$ (' #dlg '). Dialog (' Open '). dialog (' Settitle ', ' Edit User ');
$ (' #fm '). Form (' Load ', row);
url = ' http://www.jeasyui.com/demo/main/update_user.php?id= ' +row.id;
alert (row.id);
}
}
function Saveuser () {
Alert (' 1 ');
$ (' #fm '). Form (' Submit ', {
Url:url,
Onsubmit:function () {
return $ (this). Form (' Validate ');
},
Success:function (Result) {

alert (result);

var result = eval (' (' +result+ ') ');

if (result.errormsg) {
$.messager.show ({
Title: ' Error ',
Msg:result.errorMsg
});
} else {
$ (' #dlg '). Dialog (' Close '); Close the dialog
$ (' #dg '). DataGrid (' reload '); Reload the user data
}
},
Error:function (index) {
alert (index);
}
});
}
function Destroyuser () {
var row = $ (' #dg '). DataGrid (' getselected ');
if (row) {
$.messager.confirm (' Confirm ', ' is sure you want to destroy this user? ', function (r) {
if (r) {
$.post (' http://www.jeasyui.com/demo/main/destroy_user.php ', {id:row.id},function (result) {
if (result.success) {
$ (' #dg '). DataGrid (' reload '); Reload the user data
} else {
$.messager.show ({//Show error message
Title: ' Error ',
Msg:result.errorMsg
});
}
}, ' json ');
}
});
}
}
</script>
<style type= "Text/css" >
#fm {
margin:0;
padding:10px 30px;
}
. ftitle{
font-size:14px;
Font-weight:bold;
padding:5px 0;
margin-bottom:10px;
border-bottom:1px solid #ccc;
}
. fitem{
margin-bottom:5px;
}
. Fitem label{
Display:inline-block;
width:80px;
}
. Fitem input{
width:160px;
}
</style>
</body>

Application (Basic)----Easyui

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.