Blog信息 |
blog名称: 日志总数:1304 评论数量:2242 留言数量:5 访问次数:7585537 建立时间:2006年5月29日 |

| |
[Prototype(Ajax)]Spry Framework入门(四)——XML数据集排序 软件技术
lhwork 发表于 2007/1/18 10:51:51 |
页面代码:test.html
1500)this.width=500'><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2500)this.width=500'><html xmlns="http://www.w3.org/1999/xhtml" xmlns:spry="http://ns.adobe.com/spry"> 3500)this.width=500'><head> 4500)this.width=500'><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 5500)this.width=500'><title>Static Table Sample</title> 6500)this.width=500'><script type="text/javascript" src="includes/xpath.js"></script> 7500)this.width=500'><script type="text/javascript" src="includes/SpryData.js"></script> 8500)this.width=500'> 9<script type="text/javascript">500)this.width=500'>10//var dsEmployees = new Spry.Data.XMLDataSet("data/employees-01.xml", "employees/employee");11var dsEmployees = new Spry.Data.XMLDataSet("data/employees-01.xml", "employees/employee", 500)this.width=500'>{ sortOnLoad: "@id", sortOrderOnLoad: "ascending" });1213var myObserver = new Object;1415myObserver.onPreSort = function(dataSet, data)500)this.width=500'>{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>";1920 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};2223myObserver.onPostSort = function(dataSet, data)500)this.width=500'>{24 //alert("onPostSort called!");25};262728dsEmployees.addObserver(myObserver);293031500)this.width=500'></script>32500)this.width=500'>33<style>3435.even {500)this.width=500'>}{36 background-color: #eeeeee37}3839.odd {500)this.width=500'>}{40 background-color: #ffffff;41}4243500)this.width=500'></style>44500)this.width=500'>45500)this.width=500'></head>46500)this.width=500'><body>47500)this.width=500'>48500)this.width=500'><div spry:region="dsEmployees">49500)this.width=500'><table border="1">50500)this.width=500'> <tr>51500)this.width=500'> <th scope="col">Employee ID </th>52500)this.width=500'> <th scope="col">Last Name </th>53500)this.width=500'> <th scope="col">First Name </th>54500)this.width=500'> <th scope="col">Phone</th>55500)this.width=500'> <th scope="col">Username</th>56500)this.width=500'> </tr>57500)this.width=500'> <tr spry:repeat="dsEmployees" class="{ds_EvenOddRow}">58500)this.width=500'> <td>{@id}</td>59500)this.width=500'> <td>{lastname}</td>60500)this.width=500'> <td>{firstname}</td>61500)this.width=500'> <td>{phone}</td>62500)this.width=500'> <td>{username}</td>63500)this.width=500'> </tr>64500)this.width=500'></table>65500)this.width=500'>66500)this.width=500'>67500)this.width=500'></div>68500)this.width=500'><hr>69500)this.width=500'><input type=button value="Sort by ID" onclick="dsEmployees.sort('@id', 'toggle');" >70500)this.width=500'><input type=button value="Sort by Last Name" onclick="dsEmployees.sort('lastname', 'toggle');" >71500)this.width=500'><br>72500)this.width=500'><div id="info"/>73500)this.width=500'></body>74500)this.width=500'></html>employees-01.xml
1500)this.width=500'><?xml version="1.0" encoding="iso-8859-1"?> 2500)this.width=500'><employees xmlns="http://www.foo.com/employees"> 3500)this.width=500'> <employee id="123456"> 4500)this.width=500'> <lastname>Smith</lastname> 5500)this.width=500'> <firstname>Edward</firstname> 6500)this.width=500'> <phone>(415) 333-0235 </phone> 7500)this.width=500'> <username>esmith</username> 8500)this.width=500'> </employee> 9500)this.width=500'> <employee id="127937">10500)this.width=500'> <lastname>Johnson</lastname>11500)this.width=500'> <firstname>Neil</firstname>12500)this.width=500'> <phone>(415) 333-9475 </phone>13500)this.width=500'> <username>njohnson</username>14500)this.width=500'> </employee>15500)this.width=500'> <employee id="126474">16500)this.width=500'> <lastname>Williams</lastname>17500)this.width=500'> <firstname>Steve</firstname>18500)this.width=500'> <phone>(415) 333-4573 </phone>19500)this.width=500'> <username>swilliams</username>20500)this.width=500'> </employee>21500)this.width=500'> <employee id="120585">22500)this.width=500'> <lastname>Jones</lastname>23500)this.width=500'> <firstname>John</firstname>24500)this.width=500'> <phone>(415) 333-9345 </phone>25500)this.width=500'> <username>jjones</username>26500)this.width=500'> </employee>27500)this.width=500'> <employee id="127493">28500)this.width=500'> <lastname>Brown</lastname>29500)this.width=500'> <firstname>Joe</firstname>30500)this.width=500'> <phone>(415) 333-5938 </phone>31500)this.width=500'> <username>jbrown</username>32500)this.width=500'> </employee>33500)this.width=500'></employees>34500)this.width=500'> |
|
|