dojo datagrid和itemfilereadstore

时间:2010-05-18 04:49:14

标签: javascript dojo

如何更新dojox.Grid以显示最新数据?

最初我创建了空店, 然后我改变了数据以包含某些东西, 使用新数据创建新的数据存储 然后将网格数据存储区设置为新存储区。

在大多数示例中,人们在初始化商店时使用网址而不是数据。

那么如何更新网格以显示最新商店?

 // 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);

1 个答案:

答案 0 :(得分:2)

问题在于:

lgaNameSelectionStore = new dojo.data.ItemFileReadStore({data: data3});

您无法向ItemFileReadStore添加新数据(仅适用于READ), 你必须使用ItemFileWriteStore