easyui的datagrid中对记录修改,修改后如何显示在前台??

你我共享世界美好 发布于 2014/05/12 09:30
阅读 2K+
收藏 0

获取修改的记录,修改后按确定后触发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());

求大师帮忙!!!!!

加载中
0
ForEleven
ForEleven

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

你我共享世界美好
你我共享世界美好
这都试过了,都不行估计是后台写的有问题。
九二妹妹
九二妹妹
不看api文档,就来发帖问
Coffee_M
Coffee_M
+1
0
p2ng
p2ng
在点击修改按钮完成之后调用楼上的方法
返回顶部
顶部