qq_35572020 2016-10-26 03:13 采纳率: 0%
浏览 1013

easyui datagrid显示不出的问题,求各位大神帮帮小弟~

 **jsp页面代码**
<body>
    <div style="padding:8px;height:auto">
        参数项名称: <input class="easyui-validatebox" type="text" name="name"
            data-options="required:true"> 创建时间: <input
            class="easyui-datebox" name="createTime" style="width:80px">
        <a href="#" class="easyui-linkbutton" iconCls="icon-search">查找</a> <a
            href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'">添加</a>
    </div>

    <table id="tt" class="easyui-datagrid"></table>

    <script type="text/javascript">  

    $('#tt').datagrid({  
        title: "用户列表",  
        width:"100%",
        height:550,
        iconCls:"icon-save",
        rownumbers:false,
        pagination:true,
        url: 'queryList.action',  
        pageSize:10,   
        columns: [  
            [   
                {field: "user_code", title: "账号", width:"24%", align: "center"},  
                {field: "user_account", title: "密码", width:"24%", align: "center"},  
                {field: "name", title: "姓名", width: "24%", align: "center"},  
                {field: "names", title: "称呼", width: "24%", align: "center"},
                {field:'opt',title:"操作",width:"8%",align:"center",  
                     formatter:function(value,rec){  
                         var btn = "<a class='editcls' onclick='editRow('"+rec.projectname+"','"+rec.projectpackage+"')' href='javascript:void(0)>'编辑</a>";  
                         return btn;  
                     }
                 }
            ]  
        ], toolbar: [{ 
            text: '添加', 
            iconCls: 'icon-add', 
            handler: function() { 
                openDialog("add_dialog","add"); 
            } 
        }, '-', { 
            text: '修改', 
            iconCls: 'icon-edit', 
            handler: function() { 
                openDialog("add_dialog","edit"); 
            } 
        }, '-',{ 
            text: '删除', 
            iconCls: 'icon-remove', 
            handler: function(){ 
                delAppInfo(); 
            } 
        }] 
    });  

    //设置分页控件  
    var p = $('#tt').datagrid('getPager'); 
    p.pagination({  
        pageSize: 5,//每页显示的记录条数,默认为10  
        pageList: [5, 10, 15],//可以设置每页记录条数的列表  
        beforePageText: '第',//页数文本框前显示的汉字  
        afterPageText: '页    共 {pages} 页',  
        displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'  
    });  
</script>  
</body>

**后台代码**
controller
@RequestMapping(value = "queryList", method = { RequestMethod.POST,
            RequestMethod.GET })  
      public void getAllParam(HttpServletRequest request, HttpServletResponse response,  
                              @RequestParam(required = false, defaultValue = "1") Integer page, //第几页  
                              @RequestParam(required = false, defaultValue = "10") Integer rows, //页数大小  
                              @RequestParam(required = false, defaultValue = "") String paramName,  
                              @RequestParam(required = false, defaultValue = "") String createTime  
      ) throws IOException { 
            Map<String,Object> map=new HashMap<String,Object>();
            map.put("pageSize", rows);
            map.put("pageIndex",(page-1)*rows);
            try {
                List<Uase> list=  uaseService.queryList(map);
                int totl=uaseService.count();
                //设置页面数据
                Map<String,Object> jsonMap = new HashMap<String,Object>();
                jsonMap.put("total",totl);
                jsonMap.put("rows", list);
                String jsonStr = JSONObject.toJSONString(jsonMap);
                System.out.println(jsonStr);
                sendJsonData(response,jsonStr);
            } catch (Exception e) {
                e.printStackTrace();
            }
      }

        private void sendJsonData(HttpServletResponse response, String data)
            throws IOException {
        // HttpServletResponse response = ServletActionContext.getResponse();
        response.setContentType("text/html;charset=UTF-8");
         System.out.println(data);
        PrintWriter out;
        out = response.getWriter();
        out.println(data);
        out.flush();
        out.close();
    }

__**    前端就是没有数据显示**__


    这是转换后字符串型的josn数据
    {"rows":[{"already_invoiceMoney":0},{"already_invoiceMoney":0},{"already_invoiceMoney":0}],"total":64}
  • 写回答

4条回答

  • PerfectGo 2016-10-26 04:28
    关注

    field的字段名要与json数据的字段名对应

    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制