我正在尝试实现一个搜索表单,其中结果将通过 dojo 1.6 数据网格显示。我有渲染工作,我对表单提交进行了 ajax 调用,然后使用 ItemFileWriteStore 在回调函数中构建了一个 Datagrid。
function search()
{
var action = './search.json';
dojo.xhrPost({url: action, form:"searchForm",
load: function(result) {
var newStore = new dojo.data.ItemFileWriteStore({
data: {
identifier: "id",
items: JSON.parse(result),
url:'./search.json'
}
});
var grid = dijit.byId("searchResultsGrid");
if(grid == null) {
var layout = [[
{'name': 'Id', 'field': 'id', 'width': '50px'},
{'name': 'Name', 'field': 'name', 'width': '50px',editable: true,},
{'name': 'Source', 'field': 'source', 'width': '50px',editable: true,},
{'name': 'Version', 'field': 'version', 'width': '50px',editable: true,}
]];
var grid = new dojox.grid.DataGrid({
id: 'searchResultsGrid',
store: newStore,
structure: layout,
autoHeight:true, autoWidth:true, editable:true, columnReordering:true,
rowSelector: '20px'
});
grid.placeAt("gridDiv");
grid.startup();
}
else {
grid.setStore(newStore);
}
}
});
}
现在,当我尝试使网格可编辑并将更改保存到服务器时,ItemFileWriteStore 没有任何反应。所以我想切换到 JsonRestStore 以便我可以坚持。
但问题是,如何将我的表单提交绑定到 JsonRestStore 或者换句话说有没有办法将动态查询传递给 JsonRestStore ?我希望 JsonRestStore 在提交我的搜索表单时并根据搜索表单中的值获取数据。
提前致谢!