easyui的datagrid中对记录修改,修改后如何显示在前台??
获取修改的记录,修改后按确定后触发editUser():
function editUser(){
var row = $('#dg').datagrid('getSelected');
if (row){
$('#bian').dialog('open').dialog('setTitle','编辑账户');
$('#bianji').form('load',row);
url = 'update_user.php?id='+row.id;
}
}
它对应的div是:<div id="bian" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px "
closed="true" buttons="#dlg-buttons">
<div class="ftitle">编辑信息</div>
<form id="bianji" method="post" novalidate>
<div class="fitem">
<label>http服务接口名称</label>
<input name="httpServiceName" class="easyui-validatebox" required="true">
</div>
<div class="fitem">
<label>http服务请求类型</label>
<input name="httpRequestType" class="easyui-validatebox" required="true">
</div>
<div class="fitem">
<label>http 服务响应类型</label>
<input name="httpResponseType" class="easyui-validatebox" required="true">
</div>
<div class="fitem">
<label>http开始时间</label>
<input name="httpStartDateTime" class="easyui-validatebox" required="true">
</div>
<div class="fitem">
<label>http断开时间</label>
<input name="httpEndDateTime" class="easyui-validatebox" required="true">
</div>
<div class="fitem">
<label>http连接时长</label>
<input name="httpConnctionTime" class="easyui-validatebox" required="true">
</div>
<div class="fitem">
<label>http执行是否成功</label>
<input name="httpStatus" class="easyui-validatebox" required="true">
</div>
<div class="fitem">
<label>http连接描述</label>
<input name="httpConnctionDesc" class="easyui-validatebox" required="true">
</div>
<div id="dlg-buttons">
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="saveuser()" iconcls="icon-save">保存</a>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#bian').dialog('close')"
iconcls="icon-cancel">取消</a>
</div>
</form>
</div>
单击保存后触发saveuser()方法:
function saveuser(){
var result;$('#bianji').form('submit',{
url: '<%=path%>/httpLog/getHttpLogData.do',
onSubmit: function(){
return $(this).form('validate');
},
success: function(result){
result = eval('('+result+')');
}
});
$('#dg').datagrid({
columns:[[
{field:'result.httpServiceName',title:'http服务接口名称',width:60},
{field:'result.httpRequestType',title:'http服务请求类型',width:60},
{field:'result.httpResponseType',title:'http 服务响应类型',width:60},
{field:'result.httpStartDateTime',title:'http开始时间',width:60},
{field:'result.httpEndDateTime',title:'http断开时间',width:60},
{field:'result.httpConnctionTime',title:'http连接时长',width:60},
{field:'result.httpStatus',title:'http执行是否成功',width:60},
{field:'result.httpConnctionDesc',title:'http连接描述',width:60},
]]
});
后台对应的方法是:@RequestMapping("/getHttpLogData")
private void getHttpLogData(HttpServletResponse response,HttpServletRequest request)
throws IOException {
String httpServiceName=request.getParameter("httpServiceName");
String httpRequestType=request.getParameter("httpRequestType");
String httpResponseType=request.getParameter("httpResponseType");
String httpStartDateTime=request.getParameter("httpStartDateTime");
String httpEndDateTime=request.getParameter("httpEndDateTime");
String httpConnctionTime=request.getParameter("httpConnctionTime");
String httpStatus=request.getParameter("httpStatus");
String httpConnctionDesc=request.getParameter("httpConnctionDesc");
JSONObject jsonObject = new JSONObject();
JSONArray rows = new JSONArray();
Map<String, String> map = new HashMap<String, String>();
map.put("httpServiceName", httpServiceName);
map.put("httpRequestType",httpRequestType);
map.put("httpResponseType",httpResponseType);
map.put("httpStartDateTime",httpStartDateTime);
map.put("httpEndDateTime", httpEndDateTime);
map.put("httpConnctionTime",httpConnctionTime);
map.put("httpStatus", httpStatus);
map.put("httpConnctionDesc", httpConnctionDesc);
response.setCharacterEncoding("utf-8");
response.setHeader("Cache-Control", "no-cache");
response.setContentType("text/json;charset=UTF-8");
jsonObject.put("total", 1);
jsonObject.put("rows", rows);
System.out.println(jsonObject.toString());
response.getWriter().write(jsonObject.toString());
求大师帮忙!!!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在点击修改按钮完成之后调用楼上的方法
+1
不看api文档,就来发帖问
这都试过了,都不行估计是后台写的有问题。