我有一个datagrid全部设置,连接到一个XMLStore。当用户从下拉列表中选择一个月时,我希望网格只过滤那个月的数据。应该是简单的,根据每个例子。我无法弄清楚它为什么不起作用,也不知道为什么IE告诉我dataGrid对象不支持任何方法(filter,sort,setQuery)。过滤一个Dojo DataGrid
<html xmlns="http://www.w3.org/1999/xhtml">
<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/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");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dojo.data.ItemFileReadStore");
theMonth = new Date();
var month_name=new Array(12);
month_name[0]="January"
month_name[1]="February"
month_name[2]="March"
month_name[3]="April"
month_name[4]="May"
month_name[5]="June"
month_name[6]="July"
month_name[7]="August"
month_name[8]="September"
month_name[9]="October"
month_name[10]="November"
month_name[11]="December"
dojo.addOnLoad(function(){dojo.byId('monthInput').value=month_name[theMonth.getMonth()]});
var eventStore = new dojox.data.XmlStore({url: "events.xml", rootItem: "event", keyAttribute: "dateSort"});
function monthClick() {
var ctr, test, rtrn, grid;
test = dojo.byId('monthInput').value;
for (ctr=0;ctr<=11;ctr++)
{
if (test==month_name[ctr])
{
rtrn = ctr +1;
}
}
eventGrid.filter({month:rtrn});
}
</script>
</head>
<body class="pfga">
<div id="content" style="width:800px; overflow:visible" dojoType="dijit.layout.ContentPane" region="center" class="pfga">
<div dojotype="dojo.data.ItemFileReadStore" url="months.json" jsID="monthStore"></div>
<div id="pagehead" class="Heading1" >Upcoming Range Events - PF&GA</div>
<p>
<input dojoType="dijit.form.FilteringSelect" store="monthStore" searchAttr="month" name="id" id="monthInput" class="pfga" onChange="monthClick()" />
</p>
<table dojoType="dojox.grid.DataGrid" store="eventStore" query="{month:'5'}" class="pfga" style="height:500px" clientSort="false" id="eventGrid" >
<thead>
<tr>
<th field="dateSort" hidden="true">DateSort</th>
<th field="date" width="80px">Date</th>
<th field="description" width="600">Description</th>
</tr>
<tr>
<th field="time" colspan="3">Details</th>
</tr>
</thead>
</table>
</div>
</body>
</html>
作为除此之外,而点击事件完美的作品,当我尝试应用在这个页面的加载,当电网第一次加载它过滤电网的过滤器。
我试图添加一个过滤器,将它添加到上面创建的现有addOnLoad函数中,我甚至尝试将我的下拉列表的值替换为加载时我的网格的起始查询。
我从道场-interest邮件组收到的答案,并试图昨晚发布,但该网站似乎是下降。 感谢谁回答 – 2009-10-16 17:53:43