2014-11-24 63 views
0

問題是我不知道如何更新/重新存儲商店,數據網格或任何涉及此過程的代碼(代碼有點雜亂,但如果有問題關於它,請讓我知道)在dojo中設置數據存儲重新格網

在舊的實現(它工作正常),它是一個帶有textArea的過濾器,並且在這個textArea中有100個可以插入的ID的限制,並且查詢是用他們。

在請求(Get)頭中作爲參數傳遞的ID,並且數據在網格中正確恢復並繪製。

這裏的一些代碼部分可以更好地理解問題。

First.js

  gridLiveView = new LiveViewTable({ 
       "storeLink" : 'monitor/store/communications', 
       'query' : _filterWidgets.getStoredValues(), 
       'useColumns' : [...] 
      }, 


    on(selectButton, "click", function(event) { 
       _filterWidgets.storeValues(); 
       gridLiveView.set('query', _filterWidgets.getStoredValues()); 

      }); 

LiveViewTable.js

function(...) { 

var grid = declare([ SortFormatterGrid (Custom Grid) ], { 

    refreshStore : null, 
    cacheStore : null, 

    constructor : function(args) { 
     lang.mixin(this, args); 

     // store definitions 
     var _jsonStore = new SortFormatterJsonRestStore({ 
      idProperty : 'comId', 
      target : this.storeLink 
     }); 
     this.cacheStore = new SortFormatterMemoryStore({ 
      idProperty : 'comId' 
     }); 
     this.store = new Observable(new Cache(_jsonStore, 
       this.cacheStore)); 
     this.refreshStore = new SortFormatterJsonRestStore({ 
      idProperty : 'comId', 
      target : this.storeLink 
     }); 

_filterWidgets.getStoredValues()返回與過濾器的值的映射圖。

的存儲和網格是定製商店,從(道場/存儲/ JsonRest和dgrid/OnDemandGrid)

現在,情況發生了變化延長,而不是100的限制,該限制爲20000點的ID。由於這個原因,請求的標題太長,我得到一個錯誤。這就是爲什麼,這是嘗試另一種解決方案。

不是在onClickEvent(gridLiveView.set('query',_filterWidgets.getStoredValues());)上調用此方法,而是在與Second.js中的構造方法相同的級別上實現並調用另一個方法,但沒有成功。

這就是所謂的方法,加在LiveViewTable.js

update : function(queryMap) { 
      var url = 'monitor/store/communications'; 
      xmlhttp = new XMLHttpRequest(); 
      xmlhttp.open("POST", url, false); 
      xmlhttp.setRequestHeader("Content-type", "application/json"); 
      xmlhttp.send(JSON.stringify(queryMap)); 
      var data = JSON.parse(xmlhttp.responseText); 
     } 

VAR數據有,我想在表中顯示正確的數據。但我試圖在這個.store中設置一個新的商店,在這個數據庫中,但是網格總是空的。試過了this.refresh()。

所以問題是,我與變量數據有什麼關係來顯示它在網格中的內容?通過grid.set('store', ...)

this.data = data; 

this.store = new Observable(new Memory({data: data})); 
+0

請準確顯示您是如何嘗試更新商店或其數據的,因爲這很可能出現問題所在。 – 2014-11-24 19:52:28

+0

編輯,這是我試過的東西 – 2014-11-25 07:27:56

回答

1

您應該設置新店,如documentation提到:

我想這樣的事情(沒有成功)。直接重新分配store屬性不會給dgrid任何知道商店實際更改的方式。

+0

我試過this.set('store',new Memory({data:data}))和this。set('store',new Observable(new Memory({data:data}))),但它不起作用。我錯過了什麼嗎? – 2014-11-26 09:06:06

+0

假設'this'是你的dgrid實例/擴展名,該__應該工作......你可能想嘗試將你的情況減少到可行的狀態,然後重新構建備份。 – 2014-11-27 03:01:24