2
如何更新dojox.Grid以显示最新数据?dojo datagrid和itemfilereadstore
起初,我创建的空店, 然后我改变了数据包含的东西, 创建新的数据存储与新的数据 ,然后将数据存储格设置为新店。
在大多数示例中,人们在初始化商店时使用url而不是数据。
那么如何更新网格以显示最新的商店?
// Use empty grid,
var emptyData = { identifier: "UID_T", label: "UID_T", items: [] };
var lgaNameSelectionStore = new dojo.data.ItemFileReadStore({data: emptyData});
var lgaNameGridLayout = [
{name : "<span title='Agency'>Agency</span>", field : "AGENCY", width : "7em"},
{name : "<span title='Project Description'>Project Description</span>", field : "ProjectDes", width : "20em"},
{name : "<span title='Description'>Description</span>", field : "CTPPD_DESC", width : "12em", },
];
var lgaNameContainer = new dijit.layout.BorderContainer({
style: "width: 100%; height: 100%",
gutters: false,
design: "headline"
},"lgawinuid");
lgaNameGrid = new dojox.grid.DataGrid({
store: lgaNameSelectionStore,
region: "center",
structure: lgaNameGridLayout,
selectionMode: "none",
noDataMessage: "No results found."
});
lgaNameContainer.addChild(lgaNameGrid);
lgaNameContainer.startup();
//data is changed, so need to update the grid
var data3 = { identifier: "UID_T", label: "UID_T", items: [{"UID_T" : "I333","AGENCY" : "RTA","CTPPD_DESC" : "M5","ProjectDes" : "Filtration","location" : ""}]};
lgaNameSelectionStore = new dojo.data.ItemFileReadStore({data: data3});
lgaNameGrid.setStore(lgaNameSelectionStore);
电网应该更新,当您用新的数据存储调用'setStore'。我认为你的代码是正确的。你的代码有什么问题?网格没有更新? – 2010-05-20 02:27:18
是的,网格没有更新。 – portoalet 2010-05-20 05:09:25