easyui的datagrid中对记录修改,修改后如何显示在前台??-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

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());

求大师帮忙!!!!!

展开
收起
a123456678 2016-07-11 17:44:11 3374 0
1 条回答
写回答
取消 提交回答
  • a123456678

    $('#dg').datagrid("relaod"); 刷新表格

    2019-07-17 19:54:29
    赞同 展开评论 打赏
问答标签:
相关产品:
问答排行榜
最热
最新
相关电子书
更多
低代码开发师(初级)实战教程
立即下载
阿里巴巴DevOps 最佳实践手册
立即下载
冬季实战营第三期:MySQL数据库进阶实战
立即下载