开发者

dojo datagrid and itemfilereadstore

开发者 https://www.devze.com 2022-12-30 21:21 出处:网络
How do I update dojox.Grid so it displays the latest data? Initially I created the empty store, and then I changed the data to contain something,

How do I update dojox.Grid so it displays the latest data?

Initially I created the empty store, and then I changed the data to contain something, create a new data store with the new data and then set the grid datastore to the new store.

In most of the examples, people use url instead of data when they initialize the s开发者_StackOverflowtore.

So how do I update the grid to display the latest store?

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


the problem is here:

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

you can not add new data to ItemFileReadStore (is for READ only), you must use a ItemFileWriteStore

0

精彩评论

暂无评论...
验证码 换一张
取 消