jQuery 开发之EasyUI 添加数据的实例
jQuery 开发之EasyUI 添加数据的实例
1、创建toolbar:
toolbar:[{ text:'增加', iconCls:'icon-add', handler:function(){ openAddUserDialog(); } }]
2、添加dialog,里面有添加用户的表单
<div 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> </div>
3、打开对话框:
function openAddUserDialog(){ $(“#addDialog").dialog('open'); }
4、服务器端返回的json
//返回的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; } }
如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17