81,092
社区成员
发帖
与我相关
我的任务
分享
$('#dd').datagrid({
title:'财务明细列表',
method:'POST',
url:'getFinanceList.action', //请求action中的方法,需要自己自己指定
iconCls:'icon-ok',
fitColumns:true,
pagination:true,
striped:true,
nowrap:true,
singleSelect:true,
rownumbers:true,
pageSize:10,
columns:[[
{field:'ck',checkbox:true}, //显示从后台传过来的结果,title是表头
{field:'financeNo',title:'编号',width:100,align:'center'},
{field:'financeDate',title:'日期',width:100,align:'center'},
{field:'totalMoney',title:'总金额(元)',width:100,align:'center'}
]]
java代码:
List<Object> list = resultList; //resultList是你从库中查到的结果
Map<String,Object> map = new HashMap<String,Object>();
map.put("total",list.getSize());
map.put("rows",list); //total 和 rows 命名最好不要变
json = JSONObject.fromObject(map);
try {
/*设置编码格式,返回结果
* ***/
response.setContentType("text/html;charset=UTF-8");
response.getWriter().write(json.toString());
} catch (IOException e1) {
e1.printStackTrace();
}