解决方案 »

  1.   

    function get_gene_list(column, condition, keyword) {
            $("#gene_list").datagrid({
                url: "handler/gene.ashx",
                idField: "_id", fit: true, fitColumns: true, singleSelect: false, striped: true,
                rownumbers: true, nowrap: false, pagination: true, pageSize: 20,
                queryParams: ({ method: "get_gene_list", column: column, condition: condition, keyword: keyword }),
                pageList: [10, 15, 20, 30, 40, 50],
                columns: [[
                    { field: "ck", checkbox: true },
                    { field: "title", title: "媒体报道标题", width: 30, sortable: true },
                    { field: "type", title: "类型", width: 30, sortable: true,
                        formatter: function (value, rec, index) {
                            if (value == '1') {
                                return "媒体报道";
                            }
                            else if (value == '2') {
                                return "基因科普"
                            }
                            else if (value == '3') {
                                return "健康知识"
                            }
                        }
                    },
                    { field: "content", title: "内容", width: 30, sortable: true },
                    { field: "pic", title: "图片", width: 30, sortable: true },
                    { field: "priority", title: "优先级", width: 30, sortable: true },
                    { field: "append_time", title: "添加时间", width: 30, sortable: true,
                        formatter: function (value, rec, index) {
                            return convert_datetime(value);
                        }
                    }
                    ]],
                toolbar: [{
                    text: "添加",
                    iconCls: "icon-add",
                    handler: function () {
                        add_tab(false, "媒体报道数据管理", "html/gene/gene_add.html");
                    }
                }, "-", {
                    text: "修改",
                    iconCls: "icon-edit",
                    handler: function () {
                        update_gene();
                    }
                }, "-", {
                    text: '删除',
                    iconCls: 'icon-remove',
                    handler: function () {
                        del_gene();
                    }
                }
                ]
            });
        }<div data-options="region:'center',border:false">
            <table id="gene_list">
            </table>
        </div>
     public string get_gene_list(HttpContext context)
        {
            try
            {
                where _where = new where();
                _where.name = "and";
                _where.sort = "priority";
                _where.order = "-1";
                if (context.Request.Params["sort"] != null)
                {
                    _where.sort = context.Request.Params["sort"];
                }
                if (context.Request.Params["order"] != null)
                {
                    if (context.Request.Params["order"] == "asc")
                    {
                        _where.order = "1";
                    }
                    else
                    {
                        _where.order = "-1";
                    }
                }
                _where.int_count = int.Parse(context.Request.Params["rows"]);
                _where.int_start = (int.Parse(context.Request["page"]) - 1) * _where.int_count;
                string column = context.Request.Params["column"];
                string condition = context.Request.Params["condition"];
                string keyword = context.Request.Params["keyword"];
                List<string> lst_where = new List<string>();
                if (condition == "-1")
                {
                }
                else
                {
                    lst_where.Add(column + "," + condition + "," + keyword);
                }
                _where.and = lst_where;
                string json = new JavaScriptSerializer().Serialize(_where);
                return jy_gene_dal.get_gene_list(json);
            }
            catch (Exception e)
            {
                common.write_log(e.Message + e.StackTrace + e.Source);
                return "";
            }
        }
      

  2.   

    大哥,理解理解我是一个新手,咱能不用考虑查询排序什么的就给我看看怎么绑定一个Ilist<User> 到easyui datagrid里面好吗
      

  3.   

    你将查询出来的结果转化为JSON对象就可以了

    map.put("total", totalCount);    //totalCount: 总的记录数
    map.put("rows", userList);     // userList: 用dao查询出的结果集合
    this.setResult(JSONObject.fromObject(map));在action中导入这两个包
    import net.sf.json.JSONArray;
    import net.sf.json.JSONObject;
      

  4.   

    楼上正解~前后台交互用json传输就ok了。
      

  5.   

    封装个方法,把查出来的值送进去,然后变成json送到jsp给datagridpublic class DataGrid implements Serializable {
    private static final long serialVersionUID = -6380432334200957148L; private int total;
    private List rows;
    private List<Map> footer; public int getTotal() {
    return total;
    } public void setTotal(int total) {
    this.total = total;
    } public List getRows() {
    return rows;
    } public void setRows(List rows) {
    this.rows = rows;
    } public List<Map> getFooter() {
    return footer;
    } public void setFooter(List<Map> footer) {
    this.footer = footer;
    }