easyui datagrid 数据绑定 java
在后台做成了一个JSONObject对象的数据集,传到jsp上,在jsp中怎么使用啊?求高手指点迷津!!!!!!后台java做json代码:List<Card>list=...
在后台做成了一个JSONObject对象的数据集,传到jsp上,在jsp中怎么使用啊?
求高手指点迷津!!!!!!
后台java做json代码:
List<Card> list = new ArrayList<Card>();
Map<String, Object> map = new HashMap<String, Object>();
Card cd1 = new Card();
Card cd2 = new Card();
cd1.setId("1");
cd1.setName("mei");
cd2.setId("2");
cd2.setName("you");
list.add(cd1);
list.add(cd2);
map.put("total",list.size());
map.put("rows",list);
JSONObject jso = JSONObject.fromObject(map);
model.addAttribute("cardInfo",jso);
jsp代码:
// 【data-options="data:‘${cardInfo}’"】 这样用应该不对吧
<table class="easyui-datagrid" data-options="data:‘${cardInfo}’">
<thead>
<tr>
<th data-options="field:'id'">Id</th>
<th data-options="field:'name'">Name</th>
</tr>
</thead>
</table> 展开
求高手指点迷津!!!!!!
后台java做json代码:
List<Card> list = new ArrayList<Card>();
Map<String, Object> map = new HashMap<String, Object>();
Card cd1 = new Card();
Card cd2 = new Card();
cd1.setId("1");
cd1.setName("mei");
cd2.setId("2");
cd2.setName("you");
list.add(cd1);
list.add(cd2);
map.put("total",list.size());
map.put("rows",list);
JSONObject jso = JSONObject.fromObject(map);
model.addAttribute("cardInfo",jso);
jsp代码:
// 【data-options="data:‘${cardInfo}’"】 这样用应该不对吧
<table class="easyui-datagrid" data-options="data:‘${cardInfo}’">
<thead>
<tr>
<th data-options="field:'id'">Id</th>
<th data-options="field:'name'">Name</th>
</tr>
</thead>
</table> 展开
展开全部
这个东西要查文档的
easyUI中的datagrid
json 打回来都是异步的 两种方式
div中声明 或者js 中注册 建议使用js
<table class="easyui-datagrid" style="width:400px;height:250px"
//这里的url要请求你的action
data-options="url:'datagrid_data.json',fitColumns:true,singleSelect:true">
<thead>
<tr>
<th data-options="field:'code',width:100">Code</th>
<th data-options="field:'name',width:100">Name</th>
<th data-options="field:'price',width:100,align:'right'">Price</th>
</tr>
</thead>
</table>
使用datagrid 的json串格式需要固定
{
"total":239,
"rows":[
{"code":"001","name":"Name 1","addr":"Address 11","col4":"col4 data"},
{"code":"002","name":"Name 2","addr":"Address 13","col4":"col4 data"},
{"code":"003","name":"Name 3","addr":"Address 87","col4":"col4 data"},
{"code":"004","name":"Name 4","addr":"Address 63","col4":"col4 data"},
{"code":"005","name":"Name 5","addr":"Address 45","col4":"col4 data"},
{"code":"006","name":"Name 6","addr":"Address 16","col4":"col4 data"},
{"code":"007","name":"Name 7","addr":"Address 27","col4":"col4 data"},
{"code":"008","name":"Name 8","addr":"Address 81","col4":"col4 data"},
{"code":"009","name":"Name 9","addr":"Address 69","col4":"col4 data"},
{"code":"010","name":"Name 10","addr":"Address 78","col4":"col4 data"}
]
}
rows 后面放你的list
页面上封装一个 对象
public pager{
private long total;
private List<?> rows;
}
把你的数据放到这个对象里 转json 就可以了祝你成功
easyUI中的datagrid
json 打回来都是异步的 两种方式
div中声明 或者js 中注册 建议使用js
<table class="easyui-datagrid" style="width:400px;height:250px"
//这里的url要请求你的action
data-options="url:'datagrid_data.json',fitColumns:true,singleSelect:true">
<thead>
<tr>
<th data-options="field:'code',width:100">Code</th>
<th data-options="field:'name',width:100">Name</th>
<th data-options="field:'price',width:100,align:'right'">Price</th>
</tr>
</thead>
</table>
使用datagrid 的json串格式需要固定
{
"total":239,
"rows":[
{"code":"001","name":"Name 1","addr":"Address 11","col4":"col4 data"},
{"code":"002","name":"Name 2","addr":"Address 13","col4":"col4 data"},
{"code":"003","name":"Name 3","addr":"Address 87","col4":"col4 data"},
{"code":"004","name":"Name 4","addr":"Address 63","col4":"col4 data"},
{"code":"005","name":"Name 5","addr":"Address 45","col4":"col4 data"},
{"code":"006","name":"Name 6","addr":"Address 16","col4":"col4 data"},
{"code":"007","name":"Name 7","addr":"Address 27","col4":"col4 data"},
{"code":"008","name":"Name 8","addr":"Address 81","col4":"col4 data"},
{"code":"009","name":"Name 9","addr":"Address 69","col4":"col4 data"},
{"code":"010","name":"Name 10","addr":"Address 78","col4":"col4 data"}
]
}
rows 后面放你的list
页面上封装一个 对象
public pager{
private long total;
private List<?> rows;
}
把你的数据放到这个对象里 转json 就可以了祝你成功
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询