【问题标题】:Reloading of data not happening for the second request第二个请求没有重新加载数据
【发布时间】:2012-11-10 10:29:13
【问题描述】:

我有 EnhancedGrid,它在根据我对数据库的查询从 AJAX 调用获得响应后加载数据。
当我发出第一个请求时,我可以看到数据正确填充到网格中。但是,我更改了我的查询,它仍然加载以前的数据。我的响应以 JSON 格式从数据库返回正确的数据。

我尝试了所有可能的方法并使用 firebug 进行了调试,但无法获得输出。我尝试搜索类似的帖子,但它仍然对我不起作用。任何帮助将不胜感激。
我在下面粘贴我的代码。

_initialiseGrid:function(){

var layout = [
              {'name': 'Project Name', 'field': 'projectName', 'width': '200px'},
              {'name': 'Date Created', 'field': 'createdDate', 'width':       '100px',formatter:this.formatDate},
              {'name': 'Comments', 'field': 'senderComments', 'width': '250px',editable:true}                    
             ];

 dataGrid = new dojox.grid.EnhancedGrid({
            id: 'JoinProjectGrid',
            structure: layout,
            rowSelector: '20px',
            plugins: {indirectSelection: {headerSelector:true}}},
            document.createElement('div'));

}

_loadData:function(response){

     var projectList=response.retrievedList;
     var rowData = {
                    identifier: "projectId",
                    items: projectList
                   };
     dataStore = new dojo.data.ItemFileWriteStore({data: rowData});
     dataGrid.set("store",dataStore);
     dojo.byId("gridDivForJoin").appendChild(dataGrid.domNode);
     dataGrid.startup();

   }    

我尝试使用:

dataGrid.setStore(dataStore) 

这不适用于第二个请求,所以, 我使用了 dataGrid.set("store",dataStore) ,它没有加载新数据但显示前一个数据。我也试过了:

clearOnClose:true, urlPreventCache:true 

刷新网格并使用下面的代码也可以在第二次请求时清除存储。

 var newStore = new dojo.data.ItemFileReadStore({data: {  identifier: "",  items: []}});
  dataGrid.setStore(newStore);

【问题讨论】:

    标签: dojox.grid.datagrid


    【解决方案1】:

    添加之后就可以了

    dataGrid.render()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-02
      • 1970-01-01
      • 2014-09-05
      • 2023-04-10
      • 2014-08-05
      • 2022-01-21
      • 2016-03-06
      相关资源
      最近更新 更多