Ext Grid

Ext在和后端通信使用Json时,要使用"callback('Json');"这种形式,原因是[quote]grid提交分页数据的时候后面还会自动跟随一个可以说是标识的字段callback=stcCallback1001
每提交一次请求,callback就会自增,也就是说第二次就是callback=stcCallback1002
对应的,你的php文件回传json数据的时候也要带上这个值,来确定是哪次的请求所返回的结果
格式是:
stcCallback1001(
{ ‘results’: 2, ‘rows’: [
{ ‘id’: 1, ‘name’: ‘Bill’, occupation: ‘Gardener’ },
{ ‘id’: 2, ‘name’: ‘Ben’, occupation: ‘Horticulturalist’ } ]
}
);

他每次提交的数据是附加在网址后面的格式是
?start=0&limit=25&_dc=1185695314632&callback=stcCallback1001
statr:起始数据值
limit:每页数据条数
_dc:自动生成的时间戳
callback:回传的确认值

要注意的是JSON-CODE中要严格按照其格式定义:{"totalProperty:".总行数,“ROOT:".JSON_ENCODE($DATA)}
另外,在ext-js中,使用JsonReader声明所读的数据是日期时,也要注意,要不就不要声明,要声明就得确定jsondata中的日期格式与你声明的一致。

出自:[url]http://www.centuryidea.cn/index.php?tag=php[/url]
[/quote]
所以对应的服务器端的实现:[code]
String callback=request.getParameter("callback");
String json = callback+"({totalProperty:100,root:[";
json += "{col1:" + 1 + ",col2:'name" + i + "',col3:'descn" + 1 + "'}";
json += "]});";

回传的结果类似于:
stcCallback1001({totalProperty:100,root:[{col1:1,col2:'name1',col3:'descn1'}]});[/code]

在创建Ext.data.Store对象时,proxy属性使用Ext.data.ScriptTagProxy,不要使用Ext.data.HttpProxy。
[quote]
Ext API
Class Ext.data.HttpProxy
Note that this class cannot be used to retrieve data from a domain other than the domain from which the running page was served.


Class Ext.data.ScriptTagProxy
Note that if you are retrieving data from a page that is in a domain that is NOT the same as the originating domain of the running page, you must use this class, rather than HttpProxy.


[/quote]
很奇怪,使用这种形式proxy: new Ext.data.ScriptTagProxy({url:'PagingGrid.jsp'})可以正常显示,但proxy: new Ext.data.HttpProxy({url:'PagingGrid.jsp'})这种就不行(我理解错了?)。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值