struts2+dojo实现datagrid
ACTION:
package test.action; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport; public class JSONDataAction extends ActionSupport {
private String identifier="name";
private String label="name";
private List<Map<String,Object>> items=new ArrayList<Map<String,Object>>(); public JSONDataAction(){
items.clear();
Map<String,Object> mapItem=null;
for(int i=0;i<15;i++)
{
mapItem=new HashMap<String,Object>();
mapItem.put("name", "name"+i);
mapItem.put("baseFlavor", "banana"+i);
mapItem.put("mixins", "fudge"+i);
mapItem.put("calories", 280+i);
mapItem.put("fat", 16+i);
mapItem.put("source", 1+i);
mapItem.put("rating", 3+i);
items.add(mapItem);
}
} public String execute(){
return this.SUCCESS;
}
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public List<Map<String,Object>> getItems() {
return items;
}
public void setItems(List<Map<String,Object>> items) {
this.items = items;
}
}
struts.xml(注意package要继承json-default):
<package name="jsontest" extends="json-default">
<action name="getJSONResult" class="test.action.JSONDataAction">
<result type="json" />
</action>
</package>
JSP(DOJO的版本是:1.10.4):
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>One Subrow</title>
<style type="text/css">
@import "dojoroot/dijit/themes/tundra/tundra.css";
@import "dojoroot/dojox/grid/resources/tundraGrid.css";
</style>
<script type="text/javascript" src="dojoroot/dojo/dojo.js" djConfig="parseOnLoad: true"></script> <script type="text/javascript">
dojo.require("dojox.grid.DataGrid");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojo.data.ItemFileWriteStore")
</script>
</head>
<body class="tundra"> <span dojoType="dojo.data.ItemFileReadStore"
jsId="icStore" url="getJSONResult.action">
</span>
<div align="center" >
<table id="grid" dojoType="dojox.grid.DataGrid"
store="icStore"
clientSort="true"
style="width: 800px; height: 200px;">
<thead>
<tr>
<th field="name">Flavor</th>
<th field="baseFlavor" >Base Flavor</th>
<th field="calories" >Calories</th>
<th field="fat" >Fat</th>
<th field="mixins">Mixins</th>
<th field="source" >Source</th>
<th field="rating">Rating</th>
</tr>
</thead>
</table>
</div> </body>
效果:

struts2+dojo实现datagrid的更多相关文章
- struts2+dojo实现datagrid动态刷新
实现一个普通的数据库查询功能,参考了这个帖子:http://stackoverflow.com/questions/5499453/how-to-refresh-datagrid 需要注意的是动态创建 ...
- struts2 easyui实现datagrid的crud
最近两天因为项目需要,接触了easyui,要用它的datagrid实现crud.第一次做,花了一天时间才完成所有功能,昨天做另外一个模块,同样的功能只用了两个小时. 现在把第一次做datagrid时遇 ...
- struts2+jquery+easyui+datagrid+j…
一.概述 struts2提供了针对json的插件支持.常规来讲我们将如何将对象数组转成json对象在客户端直接调用呢?尤其和jquery的easyui插件配合使用,这个可能会有很多的问题需要我们解决. ...
- easyUI datagrid 分页参数page和rows
Struts2获取easyUI datagrid 分页参数page和rows 用pageHelper分页时,只要是能够获取前台传来的两个参数page和rows基本就完成了很大一部分. 获取方法:定义两 ...
- 在Strust2 使用datatimepicker 标签引发的一系列问题
问题:出现无法识别的问题 原因:Strust2.1开始,对于ajax类的标签不再使用<%@ taglib prefix="s" uri="/struts-tags& ...
- struts 2.1.8.1的sx:datetimepicker标签出现NaN错误的原因和解决办法
作者:Junsan.Jin 邮箱:junsanjin@gmail.com QQ:1305896503 本文原始地址:http://www.rsky.com.cn/Article/java/201 ...
- dojo DataGrid实现表格数据编辑的解决方案
在官网上看见的DataGrid编辑非常简单,但我实现的时候总是出现问题.经过N久的摸索,终于搞定了,期间出现了多处困难,下面说些解决办法的流程. 我实现的表格在页面加载时是不显示数据,只有通过表单像服 ...
- dojo Datagrid 实现数据删除功能
DataGrid实现数据动态刷新功能见前一个帖子:http://www.cnblogs.com/qq552048250/p/4447103.html 实现数据删除只需要向表格中动态添加按钮,并为按钮的 ...
- Struts2+Datagrid表格显示(可显示多表内容)
概述 最近学到EasyUI的Datagrid数据网格,然后就做了一个小例子,中间层利用Struts2来完成,DAO层用的是Hibernate. 数据库 数据库涉及到stuednt(name,noid, ...
随机推荐
- shell开源跳板机sshstack
笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 源码地址: https://github.com/sshstack/sshstack 为什么要写shell跳板机? ...
- CentOS 7部署Java+Mysql步骤
1.工具 putty0.7:用于远程控制服务器 winSCP5.13: ftp工具,用于向远程服务器传送文件 2.安装jdk: yum -y install java-1.8.0-openjdk ja ...
- Python 关联关系
class Boy: def __init__(self, name, girlFriend=None): # 在初始化的时候可以给一个对象的属性设置成另一个类的对象 self.girlFriend ...
- vue国际化插件
1.安装 $ npm install vue-i18n 2.引入 import VueI18n from 'vue-i18n' Vue.use(VueI18n) const i18n = new Vu ...
- poj 2251 Dungeon Master (BFS 三维)
You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of un ...
- VTP管理交换机的VLAN配置
实验要求:将Switch1设置为VTPserver.Switch2设置为VTPtransparent.Swtich3和4设置为VTPclient 拓扑如下: 涉及内容: 1.VTP的创建 2.VTP的 ...
- angular file change
AngularJs: How to check for changes in file input fields? <input type="file" onchange=& ...
- CodeForces - 1100F:Ivan and Burgers (线性基&贪心)(离线 在线)
题意:给定N个数,Q次询问,求区间最大异或和. 思路:一开始想的线性基+线段树.单次线性基合并的复杂度为20*20,结合线段树,复杂度为O(NlogN*20*20):显然,超时. 超时代码: #inc ...
- P1005 矩阵取数游戏(动态规划+高精度)
题目链接:传送门 题目大意: 给定长度为m的数列aj,每次从两端取一个数,得到2k * aj的价值(k为当前的次数,从1开始到m),总共有n行这样的数列,求最大价值总和. 1 ≤ n, m ≤ 80, ...
- CentOS下安装VirtualBox
VirtualBox在Ubtubu下的使用和Window下一样简单,下载安装包,安装运行即可.但在CentOS下需要折腾一下 ======1 下载相应的repo包:官网找到Centos7相应的repo ...