我有一个工作正常的treegrid。网格对层次结构中的列进行排序,并且工作正常。但是,我需要能够“破坏”树的层次结构,并像非树格栅那样进行排序。有没有办法在不加载两个jqGrids的情况下执行此操作(一个使用treegrid,一个没有treegrid)?
当我说我想“破坏”层次结构时,我基本上想要关闭treegrid并只是在一个普通的非树格网格中加载数据。我可以加载两个网格,但我想关闭现有网格中的treegrid。
我使用的是使用本地json数据的treegrid:
$('#heatmap').jqGrid({
datatype: 'jsonstring',
datastr: [
{id: "0", initalColumn: "0", 0: "National", 1: "65", 2: "69", 3: "73", 4: "73", 5: "69", 6: "73", 7: "77", level: "0", parent: "null", isLeaf: false, expanded: true, loaded: true},
{id: "1", initalColumn: "1", 0: "Central", 1: "63", 2: "68", 3: "71", 4: "71", 5: "65", 6: "73", 7: "75", level: "1", parent: "0", isLeaf: false, expanded: true, loaded: true},
{id: "2", initalColumn: "2", 0: "Store 1", 1: "64", 2: "69", 3: "70", 4: "70", 5: "63", 6: "73", 7: "74", level: "2", parent: "1", isLeaf: true, expanded: true, loaded: true},
{id: "3", initalColumn: "3", 0: "Store 2", 1: "60", 2: "65", 3: "76", 4: "73", 5: "68", 6: "74", 7: "77", level: "2", parent: "1", isLeaf: true, expanded: true, loaded: true},
{id: "4", initalColumn: "4", 0: "East", 1: "64", 2: "70", 3: "72", 4: "74", 5: "71", 6: "75", 7: "77", level: "1", parent: "0", isLeaf: false, expanded: true, loaded: true},
{id: "5", initalColumn: "5", 0: "Store 3", 1: "64", 2: "73", 3: "74", 4: "77", 5: "72", 6: "77", 7: "78", level: "2", parent: "4", isLeaf: true, expanded: true, loaded: true},
{id: "6", initalColumn: "6", 0: "Store 4", 1: "67", 2: "71", 3: "72", 4: "75", 5: "71", 6: "79", 7: "79", level: "2", parent: "4", isLeaf: true, expanded: true, loaded: true},
{id: "7", initalColumn: "7", 0: "Store 5", 1: "62", 2: "66", 3: "70", 4: "72", 5: "69", 6: "70", 7: "75", level: "2", parent: "4", isLeaf: true, expanded: true, loaded: true},
{id: "8", initalColumn: "8", 0: "West", 1: "66", 2: "69", 3: "75", 4: "73", 5: "70", 6: "73", 7: "77", level: "1", parent: "0", isLeaf: false, expanded: true, loaded: true},
{id: "9", initalColumn: "9", 0: "Store 6", 1: "59", 2: "67", 3: "73", 4: "69", 5: "68", 6: "71", 7: "74", level: "2", parent: "8", isLeaf: true, expanded: true, loaded: true},
{id: "10", initalColumn: "10", 0: "Store 7", 1: "64", 2: "68", 3: "73", 4: "73", 5: "67", 6: "71", 7: "76", level: "2", parent: "8", isLeaf: true, expanded: true, loaded: true},
{id: "11", initalColumn: "11", 0: "Store 8", 1: "71", 2: "69", 3: "78", 4: "75", 5: "72", 6: "74", 7: "79", level: "2", parent: "8", isLeaf: true, expanded: true, loaded: true}]
,
treeGridModel: 'adjacency',
treeGrid: true,
ExpandColumn: '0',
ExpandColClick: false,
gridComplete: function(){ if(typeof GridComplete == 'function'){GridComplete();} },
beforeSelectRow: function(rowid, e) { return false; },
onSelectRow: function(rowid){if(typeof GridClick == 'function'){GridClick(rowid);} },
scroll: false,
scrollOffset: 18,
scrollrows:false,
rownumbers: false,
pager:'#dummypager',
rowNum: 1000,
jsonReader: {
repeatitems: false,
root: function (obj) { return obj; },
page: function () { return 1; },
total: function () { return 1; },
records: function (obj) { return obj.length; }
},
colNames: ["0","","Col1","Col2","Col3","Col4","Col5","Col6","Col7"],
colModel: [{ name: "initalcolumn", hidden: true},{ name: "0", sortable: true, title: false, width:250, sorttype: "string"},{ name: "1", sortable: true, title: false, sorttype: "int", align:"right", formatter: formatter1},{ name: "2", sortable: true, title: false, sorttype: "int", align:"right", formatter: formatter2},{ name: "3", sortable: true, title: false, sorttype: "int", align:"right", formatter: formatter3},{ name: "4", sortable: true, title: false, sorttype: "int", align:"right", formatter: formatter4},{ name: "5", sortable: true, title: false, sorttype: "int", align:"right", formatter: formatter5},{ name: "6", sortable: true, title: false, sorttype: "int", align:"right", formatter: formatter6},{ name: "7", sortable: true, title: false, sorttype: "int", align:"right", formatter: formatter7}],
gridview: true,
forceFit: false,
shrinkToFint: true,
height: 'auto',
hoverrows: false,
hidegrid: false,
autowidth: true,
deselectAfterSort: true,
headertitles: false,
title: false
})
答案 0 :(得分:1)
我认为你需要做的是在变量中保存用于datastr
参数的数组。该变量可用于创建树网格或“标准”网格。如果要从Tree Grid切换到标准网格,则应该使用GridUnload方法重新创建网格。在the answer中,您将找到演示如何使用GridUnload
。