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