EasyUI使用代码 var item = "/EasyUI/DemoServlet?type="$(function(){DemoPage();})function text(){$.messager.alert('警告','警告消息');}function DemoPage(){$('#tab').datagrid({ url:'DemoServlet?type=selectDemoPage', columns:[[ {field:
var item = "/EasyUI/DemoServlet?type=" $(function(){ DemoPage(); }) function text(){ $.messager.alert('警告','警告消息'); } function DemoPage(){ $('#tab').datagrid({ url:'DemoServlet?type=selectDemoPage', columns:[[ {field:'id',title:'编号',width:100}, {field:'name',title:'姓名',width:100}, {field:'pwd',title:'密码',width:100} , {field:'age',title:'年龄',width:100} , {field:'roles',title:'角色',width:100,align:'right',formatter:function(value,row,index){ return value.rname; }}, {field:'a',title:'操作',width:100,align:'right',formatter:function(value,row,index){ return "删除 编辑";}} ]] , striped:true, pagination:true, rownumbers:true, singleSelect:true, onDblClickRow:function(rowIndex,rowData){ updateInfo(rowData); }, toolbar: [{ iconCls: 'icon-add', handler: function(){ $('#inset').window({ width:400, height:200, modal:true, title:'添加信息' }); } }], }); } function deleteInfo(id){ $.messager.confirm('确认','您确认想要删除记录吗?',function(r){ if (r){ $.messager.alert('提示','确认删除'); deleteDemo(id); } }); } function deleteDemo(id){ $.get(item+"deleteDemoById",{"id":id},function(data){ if(data==1){ $('#tab').datagrid('reload'); }else{ $.messager.alert('提示','删除失败'); } }) } function updateInfo(rowData){ $("#name").val(rowData.name) $("#id").val(rowData.id) $("#pwd").val(rowData.pwd) $("#age").val(rowData.age) $("#rname").val(rowData.roles) $('#win').window({ width:400, height:200, modal:true, title:'编辑'+rowData.name+'的信息' }); } function updateInfo2(id){ $("#name").val("") $("#id").val("") $("#pwd").val("") $("#age").val("") $("#rname").val("") $("#id").val(id) $('#win').window({ width:400, height:200, modal:true, title:'编辑'+id+'的信息' }); } function doUpdate(id){ var id = $("#id").val(); var name = $("#name").val(); var pwd = $("#pwd").val(); var age = $("#age").val(); var rname = $("#rname").val() $.post(item+"updataDemoById",{"id":id,"name":name,"pwd":pwd,"rname":rname,"age":age},function(data){ if(data==1){ $.messager.alert('提示','修改成功'); $('#tab').datagrid('reload'); }else{ $.messager.alert('提示','修改失败'); } }) $('#win').window('close'); } function insertDemo(){ var id = $("#id1").val(); var name = $("#name1").val(); var pwd = $("#pwd1").val(); var age = $("#age1").val(); var rname = $("#rname1").val() $.post(item+"insertDemo",{"id":id,"name":name,"pwd":pwd,"rname":rname,"age":age},function(data){ alert(data); if(data==1){ $.messager.alert('提示','添加成功'); $('#tab').datagrid('reload'); }else{ $.messager.alert('提示','添加失败'); } }) $('#inset').window('close'); }