dannyr's Blog
ColdFusion Delphi Flex Java .Net —— 一个都不能少!
博客园
社区
首页
新随笔
联系
管理
订阅
随笔- 93 文章- 3 评论- 319
Spry Framework入门(四)——XML数据集排序
简介
:
Spry Framework是Adobe出品的轻量级的支持Ajax的JavaScript库,以HTML为中心,使用最基本的HTML、CSS和JavaScript来实现丰富Web页面体验。
本例子演示了数据集的字段排序功能以及对数据集排序时候触发的事件的处理;代码很简单,需要讲一下sort方法,sort方法有2个入口参数:字段名和排序顺序(ascending descending toggle),前面一个就是需要排序的字段名称,第二个是指示排序顺序(从小到大还是从大到小),其中toggle为本次排序是否和上次反序,比如当前数据集按字段1升序排序,那调用sort方法后则按降序排序,反之亦然。还有一个是排序字段的数据类型,默认的Spry都是按字符串string类型排序,另外Spry提供了数字number和日期date,一共3种数据排序类型。如设置字段为数字类型:dsPhotos.setColumnType("@width", "number");
顺便做了个数据交替显示的功能。
试验环境
:
操作系统:windowsXP Sp2
浏览器:FireFox 2.0
WEB服务器:IIS 5.0
Spry库:Spry_P1_3_08-11
安装
:
从
http://labs.adobe.com/technologies/spry/
下载安装包,目前版本为Spry_P1_3_08-11.zip,解开后把includes目录复制到自己的IIS虚拟目录上即可。
页面代码
:
test.html
1
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
2
<
html
xmlns
="http://www.w3.org/1999/xhtml"
xmlns:spry
="http://ns.adobe.com/spry"
>
3
<
head
>
4
<
meta
http-equiv
="Content-Type"
content
="text/html; charset=iso-8859-1"
/>
5
<
title
>
Static Table Sample
</
title
>
6
<
script
type
="text/javascript"
src
="includes/xpath.js"
></
script
>
7
<
script
type
="text/javascript"
src
="includes/SpryData.js"
></
script
>
8
9
<
script
type
="text/javascript"
>
10
//
var dsEmployees = new Spry.Data.XMLDataSet("data/employees-01.xml", "employees/employee");
11
var
dsEmployees
=
new
Spry.Data.XMLDataSet(
"
data/employees-01.xml
"
,
"
employees/employee
"
,
{ sortOnLoad:
"
@id
"
, sortOrderOnLoad:
"
ascending
"
}
);
12
13
var
myObserver
=
new
Object;
14
15
myObserver.onPreSort
=
function
(dataSet, data)
{
16
//
alert("onPreSort called!");
17
var
info
=
document.getElementById(
"
info
"
);
18
info.innerHTML
=
"
<table><tr><th>Last Sort Columns</th><th>Sort Order</th></tr><tr><td>
"
+
data.oldSortColumns
+
"
</td><td>
"
+
data.oldSortOrder
+
"
</td></tr></table>
"
;
19
20
info.innerHTML
+=
"
<table><tr><th>New Sort Columns</th><th>Sort Order</th></tr><tr><td>
"
+
data.newSortColumns
+
"
</td><td>
"
+
data.newSortOrder
+
"
</td></tr></table>
"
;
21
}
;
22
23
myObserver.onPostSort
=
function
(dataSet, data)
{
24
//
alert("onPostSort called!");
25
}
;
26
27
28
dsEmployees.addObserver(myObserver);
29
30
31
</
script
>
32
33
<
style
>
34
35
.even
{
}
{
36
background-color
:
#eeeeee
37
}
38
39
.odd
{
}
{
40
background-color
:
#ffffff
;
41
}
42
43
</
style
>
44
45
</
head
>
46
<
body
>
47
48
<
div
spry:region
="dsEmployees"
>
49
<
table
border
="1"
>
50
<
tr
>
51
<
th
scope
="col"
>
Employee ID
</
th
>
52
<
th
scope
="col"
>
Last Name
</
th
>
53
<
th
scope
="col"
>
First Name
</
th
>
54
<
th
scope
="col"
>
Phone
</
th
>
55
<
th
scope
="col"
>
Username
</
th
>
56
</
tr
>
57
<
tr
spry:repeat
="dsEmployees"
class
="{ds_EvenOddRow}"
>
58
<
td
>
{@id}
</
td
>
59
<
td
>
{lastname}
</
td
>
60
<
td
>
{firstname}
</
td
>
61
<
td
>
{phone}
</
td
>
62
<
td
>
{username}
</
td
>
63
</
tr
>
64
</
table
>
65
66
67
</
div
>
68
<
hr
>
69
<
input
type
=button
value
="Sort by ID"
onclick
="dsEmployees.sort('@id', 'toggle');"
>
70
<
input
type
=button
value
="Sort by Last Name"
onclick
="dsEmployees.sort('lastname', 'toggle');"
>
71
<
br
>
72
<
div
id
="info"
/>
73
</
body
>
74
</
html
>
employees-01.xml
1
<?
xml version="1.0" encoding="iso-8859-1"
?>
2
<
employees
xmlns
="http://www.foo.com/employees"
>
3
<
employee
id
="123456"
>
4
<
lastname
>
Smith
</
lastname
>
5
<
firstname
>
Edward
</
firstname
>
6
<
phone
>
(415) 333-0235
</
phone
>
7
<
username
>
esmith
</
username
>
8
</
employee
>
9
<
employee
id
="127937"
>
10
<
lastname
>
Johnson
</
lastname
>
11
<
firstname
>
Neil
</
firstname
>
12
<
phone
>
(415) 333-9475
</
phone
>
13
<
username
>
njohnson
</
username
>
14
</
employee
>
15
<
employee
id
="126474"
>
16
<
lastname
>
Williams
</
lastname
>
17
<
firstname
>
Steve
</
firstname
>
18
<
phone
>
(415) 333-4573
</
phone
>
19
<
username
>
swilliams
</
username
>
20
</
employee
>
21
<
employee
id
="120585"
>
22
<
lastname
>
Jones
</
lastname
>
23
<
firstname
>
John
</
firstname
>
24
<
phone
>
(415) 333-9345
</
phone
>
25
<
username
>
jjones
</
username
>
26
</
employee
>
27
<
employee
id
="127493"
>
28
<
lastname
>
Brown
</
lastname
>
29
<
firstname
>
Joe
</
firstname
>
30
<
phone
>
(415) 333-5938
</
phone
>
31
<
username
>
jbrown
</
username
>
32
</
employee
>
33
</
employees
>
34
posted @ 2006-10-26 15:52
dannyr|一个都不能少!
阅读(2131)
评论(2)
编辑
收藏
网摘
所属分类:
Spry
发表评论
679351
回复
引用
#1楼
2007-03-15 21:59 |
zltang[未注册用户]
请问为什么中文的不能显示和排序
回复
引用
#2楼
2007-03-19 08:44 |
dannyr[未注册用户]
应该是字符集的缘故,中文是可以显示并排序的!
刷新评论列表
刷新页面
返回页首
发表评论
昵称:
[登录]
[注册]
主页:
邮箱:
(仅博主可见)
验证码:
看不清,换一个
评论内容:
登录
注册
[使用Ctrl+Enter键快速提交评论]
0
540807
链接:
切换模板
导航:
网站首页
社区
新闻
博问
闪存
网摘
招聘
找找看
Google搜索
China-pub 计算机图书网上专卖店!6.5万品种 2-8折!
China-Pub 计算机绝版图书按需印刷服务
历史上的今天:
2004-10-26
秋夜寄邱二十二员外
2004-10-26
不基于NTFS权限的CVSNT权限设置
相关文章:
最新IT新闻:
Twitter无处不在 魔兽世界Twitter发送器插件发布
Firefox 3.5匆忙推出漏洞多 Mozilla本月将更新
预测:Twitter最可能收购的十家公司
网易澄清:与暴雪合资公司仅提供技术支持
杰克逊悼念仪式或成史上最大规模Web活动
相关链接:
公告
我的联系方式:
MSN dannyr@163.com
QQ 563178
20060606新计数器
Detail
<
2006年10月
>
日
一
二
三
四
五
六
24
25
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
与我联系
发短消息
搜索
常用链接
我的随笔
我的空间
我的短信
我的评论
更多链接
我的参与
我的新闻
最新评论
我的标签
留言簿
给我留言
查看留言
随笔分类
.Net技术(22)
(rss)
C++(9)
(rss)
ColdFusion(5)
(rss)
Delphi(2)
(rss)
DevExpress(1)
(rss)
Flex技术(29)
(rss)
Java(4)
(rss)
Laszlo(9)
(rss)
Spry(9)
(rss)
生活随笔(10)
(rss)
杂项(13)
(rss)
随笔档案
2008年6月 (1)
2008年5月 (2)
2007年9月 (2)
2007年8月 (1)
2007年7月 (3)
2007年1月 (1)
2006年12月 (2)
2006年11月 (1)
2006年10月 (6)
2006年9月 (1)
2006年8月 (4)
2006年7月 (1)
2006年6月 (4)
2006年5月 (4)
2006年4月 (2)
2006年1月 (1)
2005年12月 (1)
2005年11月 (1)
2005年10月 (2)
2005年8月 (1)
2005年7月 (1)
2005年6月 (1)
2005年5月 (1)
2005年4月 (1)
2005年3月 (2)
2005年2月 (1)
2005年1月 (3)
2004年12月 (9)
2004年11月 (9)
2004年10月 (9)
2004年9月 (3)
2004年8月 (2)
2004年7月 (6)
2004年6月 (4)
文章分类
ColdFusion
(rss)
Flex技术(3)
(rss)
文章档案
2004年6月 (3)
我的链接
Trademan
(rss)
www.k-zone.cn
(rss)
呼呼堂
(rss)
牛皮糖
(rss)
最新评论
1. re: 贴个Jsp里嵌入Flex的例子
web xml 中加入: <jsp-config> <taglib> <taglib-uri>FlexTagLib</taglib-uri> <t... (aaa1421)
2. re: 贴个Jsp里嵌入Flex的例子
您好,flex标签是不是需要什么文件才能在jsp中嵌入mxml代码啊?能发一个给我么,我的邮箱az235@sina.com (az235)
3. re: 安装.Net的痛苦经历!
关键的地方居然一句话带过了:实在是。。
我把Net FrameWork 1.1 Configuration所有的设置胡乱的搞了一通,竟然Pass了 (孤剑)
4. re: 贴个Jsp里嵌入Flex的例子
你好,我实验了以下,怎么也找不到FlexTagLib,需要的jar文件能发给我一下吗?
lofersjj@163.com,谢谢! (hefeng)
5. re: TCP穿透NAT的C++版
这个也可以写出来吗?老兄来点实际的行不行, (nn)
阅读排行榜
1. 任意对象数组ArrayList的排序法(可自定义排序字段、排序方向)(9860)
2. ASP.NET动态加载用户控件的页面生成过程(9373)
3. Flex RemoteObject 简单应用Demo(7717)
4. 征集比较完善的权限管理方案!(最好有C#方案)(7075)
5. Flex2.0文件上传功能(Flex2.0正式版)(6429)
6. 关于上个Flex-Jsp-DB例子中Flex和Jsp传递中文参数问题的解决方法!(Tomcat服务器)(6375)
7. 贴个Flex-Jsp-Mysql简单结合例子(5772)
8. DeKlarit:一个不错的top-down CG工具(4824)
9. Rich Client Fashion(转载)+乱弹(4527)
10. Flex2.0实现文件上传功能(服务器为ASP.NET)(4206)
评论排行榜
1. DeKlarit:一个不错的top-down CG工具(24)
2. 关于上个Flex-Jsp-DB例子中Flex和Jsp传递中文参数问题的解决方法!(Tomcat服务器)(17)
3. Flex2.0实现文件上传功能(服务器为ASP.NET)(17)
4. 如何关闭子线程?征集析构函数与多线程的讨论!(16)
5. 神影无踪-廖添丁FlashGame(15)
6. 征集比较完善的权限管理方案!(最好有C#方案)(13)
7. 贴个Flex-Jsp-Mysql简单结合例子(11)
8. ASP.NET动态加载用户控件的页面生成过程(11)
9. 体验 Delphi2005's ECO II 空间技术(10)
10. Flex2.0文件上传功能(Flex2.0正式版)(10)