easyui datagrid 怎么绑定Model数据 easyuidatagridmvcJquery 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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 ""; } } 大哥,理解理解我是一个新手,咱能不用考虑查询排序什么的就给我看看怎么绑定一个Ilist<User> 到easyui datagrid里面好吗 你将查询出来的结果转化为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; 楼上正解~前后台交互用json传输就ok了。 封装个方法,把查出来的值送进去,然后变成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; } uploadify-3.1在FF跟chrome下正常,IE下无法显示 《高手请进》请问如何获得内网IP? Javascript 获取ID 怎样防止视频被迅雷下载 如何实现该图片滚动效果 请问大家怎么样隐藏表格的一行呀,谢谢 如何判断记录位置? 判断一个网站的exe或zip或xml或js是否存在, jq中点击checkbox事件,记住密码 下拉框某些值不能呗选中 The server encountered an internal error () that prevented it from fulfilling t 求教Extjs 4 关于Ext.grid.Panel数据显示问题
$("#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 "";
}
}
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;
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;
}