【问题标题】:dojo EnhancedGrid reset nestedSortdojo EnhancedGrid 重置 nestedSort
【发布时间】:2016-04-28 15:07:04
【问题描述】:

我正在使用带有 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);
    });
}

【问题讨论】:

    标签: dojo


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2013-11-26
      • 2012-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-14
      • 1970-01-01
      相关资源
      最近更新 更多