This article mainly introduces relevant information about the examples of adding data in EasyUI developed by jQuery. I hope this article can help everyone understand and master this part of the content. Friends who need it can refer to it. I hope it can help everyone.
JQuery Development EasyUI Example of Adding Data
1. Create toolbar:
toolbar:[{ text:'增加', iconCls:'icon-add', handler:function(){ openAddUserDialog(); } }]
2. Add a dialog, which contains a form for adding users
<p id="addDialog" data-options="closed:true,modal:true,title:'addUser', buttons:[{ text:'保存', iconCls:'icon-add', handler:function(){ //addUser(); $('#addForm').form('submit',{url:'${rootPath}/user_add.action',success:function(data){ var result = JQuery.parseJSON(data); if(result.success){ //$("#datagrid").datagrid('reload'); $("#addDialog").dialog('close'); //把插入的数据添加到最后一行 //$("#datagrid").datagrid('appenRow',result.obj); $("#datagrid").datagrid('insertRow',{ index:0; row:result.obj//obj里面存了user对象 }); } $.message.show({ title:'提示', msg:obj.msg }); }}); } }]" class="easyui-dialog"> <table> <tr> <th></th> <tr/> </table> </p>
3. Open the dialog box:
function openAddUserDialog(){ $(“#addDialog").dialog('open'); }
4. json returned by the server
//返回的json public class Json implements java.io.Serializable { /** * */ private static final long serialVersionUID = 1L; private boolean success = false; private String msg = ""; private Object obj = null; public boolean isSuccess() { return success; } public void setSuccess(boolean success) { this.success = success; } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } public Object getObj() { return obj; } public void setObj(Object obj) { this.obj = obj; } }
Related recommendations:
php lazy function automatically adds data
C#How to update and add data to Excel table using Ado.Net
Example sharing jQuery EasyUI development skills summary
The above is the detailed content of Detailed explanation of adding data instances in jQuery EasyUI. For more information, please follow other related articles on the PHP Chinese website!