dojo EnhancedGrid重置nestedSort

时间:2016-04-28 15:07:05

标签: dojo

我正在使用带有NestedSorting的dojo(1.8)EnhancedGrid进行动态搜索。因为在我使用setStore之前,我希望重置最后一个排序的列数可以不同。当我单击以对网格进行排序时,dojo会将最后一次搜索的最后一种添加到新请求中。我想每次使用setNewDataToGrid()时都没有任何排序。有没有办法实现这个目标?

我的测试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);
    });
}

1 个答案:

答案 0 :(得分:0)

尝试:grid.render();或grid.startup();而不是每次都将商店设置为空(&#34;&#34;)。 如果这对于api https://dojotoolkit.org/api/没有帮助,请在创建时查看哪些属性适合您的网格功能,就像您可以添加autoRender:true一样。 附:尝试使用新版本,v1.8存在问题,尤其是在使用IE时。

相关问题