浏览 1369 次
|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
时间:2007-11-17
paging.html代码如下:
paging.js 代码
paging_data.jsp 代码
FenLog.java 代码
请求后,从服务器返回的JSON代码如下:
声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |
|
时间:2007-11-17
[quote="crabboy"]回调函数没有构造问题。在你的代码后给你一段代码,你试试看. System.out.println(builder.toString()); boolean scriptTag = false; String cb = request.getParameter("callback"); if (cb != null) { scriptTag = true; response.setContentType("text/javascript"); } else { response.setContentType("application/x-json"); } if (scriptTag) { out.write(cb + "("); } out.print(builder.toString()); if (scriptTag) { out.write(");"); } return null;[/quote]
问题已解决,非常感谢crabboy会员
|
|
| 返回顶楼 | |
|
时间:2007-11-17
如果不是跨应用的url不要使用Ext.data.ScriptTagProxy,直接使用HttpProxy,就不用考虑回调函数了。
|
|
| 返回顶楼 | |
|
时间:2007-11-17
[quote="tongyi121"]如果不是跨应用的url不要使用Ext.data.ScriptTagProxy,直接使用HttpProxy,就不用考虑回调函数了。[/quote] 请问怎样直接使用HttpProxy? |
|
| 返回顶楼 | |
|
时间:2008-03-07
vjanev 写道 [quote="crabboy"]回调函数没有构造问题。在你的代码后给你一段代码,你试试看. System.out.println(builder.toString()); boolean scriptTag = false; String cb = request.getParameter("callback"); if (cb != null) { scriptTag = true; response.setContentType("text/javascript"); } else { response.setContentType("application/x-json"); } if (scriptTag) { out.write(cb + "("); } out.print(builder.toString()); if (scriptTag) { out.write(");"); } return null;[/quote] 问题已解决,非常感谢crabboy会员 我也遇到了 缺少";" 问题, servlet输出的代码也和上面例子一样. 我看这段代码, 也没找到解决问题的方法,那位高手能指点指点呢?
|
|
| 返回顶楼 | |
|
时间:2008-04-17
我的是网上最简单的jsp读取例子,如果用Ext.data.HttpProxy就不报错,用Ext.data.ScriptTagProxy 错误信息第2行,excepted ";",但是主要的是不管用那个都显示不出数据!!!我用的2.02版本
|
|
| 返回顶楼 | |
|
时间:2008-04-17
告诉你:
所有文件 存为 utf-8格式 |
|
| 返回顶楼 | |
|
时间:2008-04-18
crabboy 写道 告诉你:
所有文件 存为 utf-8格式 所有都存为utf=8了,还是不显示数据,还没有错误,我的后台数据是: data.jsp
<body>
<%
String start = request.getParameter("start");
String limit = request.getParameter("limit");
try {
int index = Integer.parseInt(start);
int pageSize = Integer.parseInt(limit);
String json = "{totalProperty:100,root:[";
for (int i = index; i < pageSize + index; i++) {
json += "{id:'" + i + "',name:'name" + i + "',descn:'descn" + i + "'}";
if (i != pageSize + index - 1) {
json += ",";
}
}
json += "]}";
response.getWriter().write(json);
System.out.println("========="+json);
} catch(Exception ex) {
}
%>
</body>
grid.js
Ext.onReady(function() {
var sm = new Ext.grid.CheckboxSelectionModel();
var cm = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),
sm,
{header:'编号',dataIndex:'id',width:40,sortable:true},
{header:'名称',dataIndex:'name',width:40},
{header:'描述',dataIndex:'descn',width:40}
]);
cm.defaultSortable = true;
var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url:'data.jsp'
}),
reader: new Ext.data.JsonReader({
root: 'root',
totalProperty: 'totalProperty',
id: 'id',
fields: [ 'id','name','descn' ]
})
});
var grid = new Ext.grid.GridPanel({
el: 'grid',
ds: ds,
cm: cm,
sm: sm,
width: 800,
height: 300,
loadMask: true,
bbar: new Ext.PagingToolbar({
pageSize: 20,
store: ds,
displayInfo: true,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "没有记录"
})
});
grid.render();
ds.load({params:{start:0, limit:10}});
});
grid.html
<html>
<head>
<title>grid.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css" />
<script type="text/javascript" src="extjs/ext-base.js"></script>
<script type="text/javascript" src="extjs/ext-all.js"></script>
<script type="text/javascript" src="extjs/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="js/grid.js"></script>
</head>
<body>
<div id="grid" style="height:265px;"></div>
</body>
</html>
|
|
| 返回顶楼 | |
|
时间:2008-04-19
不管是用new Ext.data.ScriptTagProxy 还是其他的
确保后台能够取到start,limit,callback 参数 在json数据的前面加上 callback参数的值 格式是(c#) 代码 strToResponse = strCallback + "(" + json.ToString() + ")"; |
|
| 返回顶楼 | |




