2016-04-28 48 views
0

我正在使用dojo(1.8)EnhancedGrid with NestedSorting用於我的動態搜索。由於每次搜索的列數都可能不同,因此我希望在使用setStore之前重置最後一次排序。當我點擊排序網格時,dojo將當前最後一次搜索添加到新請求中。我想每次使用setNewDataToGrid()時都沒有任何排序。有沒有一種方法可以實現這一點?dojo EnhancedGrid重置nestedSort

我的測試HTML:

<div id="testGrid"></div> 
<span onClick="setNewDataToGrid();">test</span> 

我的網格是:

require([ 
     "dojox/grid/EnhancedGrid", 
     "dojox/data/JsonRestStore", 
     "dojox/grid/enhanced/plugins/NestedSorting", 
     "dojox/grid/enhanced/plugins/Exporter", 
     "dojo/domReady!", 
     "dojox/grid/cells/dijit" 
    ], function(DataGrid, JsonRestStore) { 
     var store = new JsonRestStore({target:"/basis/contact/"}); 
     var grid = new DataGrid({ 
      style:  "height: 400px;", 
      store:  store, 
      query:  "", 
      plugins: {"nestedSorting": true}, 
      structure: [ 
       { 
        defaultCell: { editable: false }, 
        cells:  [ 
         { name: "ID", field: "id", width: "50px", }, 
         { name: "Name", field: "p_familienname", width: "200px"}, 
        ] 
       } 
      ], 
      selectionMode: "single" 
     }, "testGrid"); 
     grid.startup(); 
    }); 

我的復位功能是:

function setNewDataToGrid() { 
    require(["dojox/data/JsonRestStore"], function (JsonRestStore) { 
     var grid = dijitRegistry.byId("testGrid"); 
     var dataStore = new JsonRestStore({target: "/basis/member/"}); 
     // here I'm adding the new layout with other columns 
     [...] 
     grid.setStructure(newColumns); 
     //insert reset sort here! 
     var query = "somethingnew..." 
     gid.setStore(dataStore, query); 
    }); 
} 

回答

0

嘗試:grid.render();或grid.startup();而不是每次將存儲設置爲空(「」)。 如果這沒有幫助,請在api https://dojotoolkit.org/api/的幫助下查看創建時的哪些屬性適合您的網格功能,如可以添加autoRender:true。 P.S.嘗試使用新版本,v1.8有問題,特別是如果您使用IE。