【发布时间】: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