我有一个从 XML 数据存储加载的 DataGrid,所有这些都是以声明方式创建的。我想在加载数据时设置排序。我发现的所有示例都涉及以编程方式执行此操作,并暗示它应该以声明方式可行。
这是创建数据源的代码。
<head>
<title>Untitled Page</title>
<style type="text/css">
@import "StyleSheet.css";
@import "js/dojotoolkit/dijit/themes/pfga/pfga.css";
@import "js/dojotoolkit/dojo/resources/dojo.css";
@import "js/dojotoolkit/dojox/grid/resources/Grid.css";
@import "js/dojotoolkit/dojox/grid/resources/pfgaGrid.css";
</style>
<script src="js/dojotoolkit/dojo/dojo.js" type="text/javascript" djConfig="parseOnLoad: true"></script>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dojox.grid.DataGrid");
dojo.require("dojox.data.XmlStore");
dojo.require("dijit.layout.ContentPane");
</script>
</head>
<body class="pfga">
<div dojotype="dojox.data.XmlStore" url="events.xml" jsID="eventStore"></div>
<table dojoType="dojox.grid.DataGrid" store="eventStore" class="pfga" style="height:500px" clientSort="true" jsID="eventGrid">
<thead>
<tr>
<th field="date" width="80px">Date</th>
<th field="description" width="600">Description</th>
<th field="DateID" sortDesc="true" hidden="false">DateSort</th>
</tr>
<tr>
<th field="time" colspan="3">Details</th>
</tr>
</thead>
</table>
</body>