更新/更新dojo数据网格与新的商店价值组合框值更改
问题描述:
我有一个组合框和我的网页中的数据网格。当用户更改组合框的值时,我不得不用新的父项的子节点更新网格。我如何使用Dojo组合框和数据网格来实现这一点。更新/更新dojo数据网格与新的商店价值组合框值更改
以下代码段不适用于我。当我使用新的json数据在网格上使用setStore方法时。
<div dojoType="dojo.data.ItemFileReadStore" jsId="store" url="/child/index/"></div> // grid store
<div dojoType="dojo.data.ItemFileReadStore" jsId="parentStore" url="/parent/index/"></div> // combo box store
//组合框
<input dojoType="dijit.form.ComboBox" value="Select" width="auto" store="parentStore" searchAttr="name" name="parent" id="parent" onchange="displayChildren()">
// MY GRID
<table dojoType="dojox.grid.DataGrid" jsId="grid" store="store" id="display_grid"
query="{ child_id: '*' }" rowsPerPage="2" clientSort="true"
singleClickEdit="false" style="width: 90%; height: 400px;"
rowSelector="20px" selectionMode="multiple">
<thead>
<tr>
<th field="child_id" name="ID" width="auto" editable="false"
hidden="true">Text</th>
<th field="parent_id" name="Parent" width="auto"
editable="false" hidden="true">Text</th>
<th field="child_name" name="child" width="300px" editable="false">Text</th>
<th field="created" name="Created Date" width="200px"
editable="false" cellType='dojox.grid.cells.DateTextBox'
datePattern='dd-MMM-yyyy'></th>
<th field="last_updated" name="Updated Date" width="200px"
editable="false" cellType='dojox.grid.cells.DateTextBox'
datePattern='dd-MMM-yyyy'></th>
<th field="child_id" name="Edit/Update" formatter="fmtEdit"></th>
</tr>
</thead>
</table>
//平变化父组合框在我试图重新加载与新数据网格的方法服务器。
function displayChildren() {
var selected = dijit.byId("parent").attr("value");
var grid = dojo.byId('display_grid');
var Url = "/childsku/index/parent/" + selected;
grid.setStore(new dojo.data.ItemFileReadStore({ url: Url }));
}
但它没有更新我的网格与新的内容。每次用户更改组合框值时,我都不知道如何刷新网格。
谁能帮我解决这个问题...
,如果我得到两个ItemFileReadStore和ItemFileWrireStore的解决方案,我会很高兴。
感谢
拉吉..
答
我认为你缺少取()一步。以下是我将如何编码您的事件处理程序:
function displayChildren() {
var selected = dijit.byId("parent").attr("value");
var store = new dojo.data.ItemFileWriteStore({ // Read or Write, no difference
url: "/childsku/index/parent/" + selected
});
// Fetch the grid with the data
store.fetch({
query : {},
onComplete : function(items, request) {
var grid = dojo.byId('display_grid');
if (grid.selection !== null) {
grid.selection.clear();
}
grid.setStore(store);
},
error: function(message, ioArgs) { alert(message+"\nurl: "+ioArgs.url); }
});
}