jqGrid 树网格不排序,除非节点被分组



我有一个jqGrid TreeGrid,我从排序良好的服务器加载,其中节点包含资产(叶(。 某些资产被分组到这些节点可展开的程序集中。 当树首次加载时,树看起来很完美,并且可以在所有节点中正确排序。 所有叶节点都完全符合预期,较低级别的叶节点也与父节点进行相应的排序,跨单击的任何可排序列标题。

但我也允许用户在没有分组的"平面视图"中加载树。 树从已根据第一列排序的服务器再次加载。 平面视图删除程序集布局,并将所有资源作为叶返回。 树以服务器呈现的完美顺序包含所有节点。 但在"平面视图"中,树不再通过单击任何可排序的列标题进行排序。 因此,我的代码中的某些内容很可能没有正确定义。

以下是 TreeGrid 创建代码(使用版本 4.5.4(:

$('#tree').jqGrid(
{
datatype: 'local',
colNames:['Name','ID','Description','Asset Acct','Cost','Cond','Depreciation Acct','Status','','','','','','','','','','','',''],
colModel:[
{name:'aname',width:'100',resizable:true,sorttype:'text'},
{name:'id',width:50,align:'center',resiable:false,sorttype:'int'},
{name:'adescription',width:'200',resizable:true}, 
{name:'a_account',width:'100',sorttype:'text'}, 
{name:'pcost',width:'50',align:'right',formatter:formatPrice,sortable:false}, 
{name:'pcondition',width:'30',align:'center',formatter:formatCondition,sortable:false}, 
{name:'d_account',width:'100',sorttype:'text'}, 
{name:'ssold',width:'30',align:'center',formatter:formatDisposition,sortable:false},
{name:'pdate',hidden:true},
{name:'pvendor',hidden:true},
{name:'sdescription',hidden:true},
{name:'sdate',hidden:true},
{name:'sprice',hidden:true},
{name:'sexpense',hidden:true},
{name:'alocation',hidden:true},
{name:'apo',hidden:true},
{name:'asn',hidden:true},
{name:'awdate',hidden:true},
{name:'aid',hidden:true}, 
{name:'did',hidden:true}
],
gridview: false,
height: 'auto',
autowidth: true,
rowNum: 10000,
sortname: 'aname',
treeGrid: true,
treeGridModel: 'adjacency',
treedatatype: 'local',
treeIcons: {plus:'ui-icon-folder-collapsed',minus:'ui-icon-folder-open',leaf:'ui-icon-document'},  
ExpandColumn: 'aname',
ExpandColClick: true,
loadonce:true,
width: '100%',
scrollOffset: 0
});

以及从数据库获取资产的服务器端 PHP 函数:

// recursive function (when loading assets in group view)
function getAssets($parentid=0, $level=0, $hierarchicalview=1)
{
$sql = "SELECT a.*, (SELECT COUNT(*) FROM mod_accounting_assets WHERE parentid=a.id) AS childCount FROM mod_accounting_assets a ";
if($hierarchicalview == 1) { $sql .= "WHERE a.parentid={$parentid} "; } else { $sql .= "WHERE adescription <> 'Asset Grouping'"; }
$sql .= "ORDER BY LOWER(a.aname)";
$stmt = AMDB::selectStatement($sql);
while($data = $stmt->fetch(PDO::FETCH_ASSOC))
{
$data['pdate'] = fromMySQLDate($data['pdate']);
$data['sdate'] = $data['sdate'] != "0000-00-00" ? fromMySQLDate($data['sdate']) : "";
$data['awdate'] = $data['awdate'] != "0000-00-00" ? fromMySQLDate($data['awdate']) : "";
$data['a_account'] = am_getCOAName($data['aid'], 1, 1);
$data['d_account'] = am_getCOAName($data['did'], 1, 1);
$data['loaded'] = true;
$data['parent'] = $data['parentid'] == 0 ? "null" : $data['parentid'];
// showing in grouped format
if($hierarchicalview == 1)
{
$data['level'] = $level;
$data['isLeaf'] = $data['childCount'] == 0 ? true : false;
// have children, sum them, and recurse deeper
if($data['childCount'])
{
$sql = "SELECT SUM(pcost) FROM mod_accounting_assets WHERE parentid={$data['id']}";
$data['expanded'] = false;
$data['pcost'] = AMDB::selectColumn($sql);
$assets[] = $data;
$assets = array_merge($assets, getAssets($data['id'], $level+1, $hierarchicalview));
}
// no children
else
{
$data['level'] = $level;
$data['isLeaf'] = $data['aname'] != "Asset Grouping";
$assets[] = $data;
}
}
// showing flat view
else
{
$data['level'] = 0;
$data['isLeaf'] = $data['aname'] != "Asset Grouping";  
$assets[] = $data;
}
}
return $assets;
}

以及用资产加载树的 javascript 函数:

// load the tree from json encoded array
function loadTree(data)
{
$('#tree')[0].addJSONData({
total: 1,
page: 1,
records: data.length,
rows: data
});
$('#tree').trigger('reloadGrid');
}

为了最初在页面加载时加载树,我们使用 php 将资产放入分组模式下的数组中,使用 php json_encode(( 将其编码为 JSON,然后在 document.ready(( 事件上嵌入对 loadTree($assets( 的调用,如下所示:

echo("n
$(document).on('ready', function()n
{n
// load the treen
loadTree({$assets});n
});n
";

当用户想要从组视图更改为平面视图时,ajax 请求将发送到服务器,然后将以 JSON 编码字符串返回的结果资产传递给相同的 loadTree(assets( javascript 函数。这里没有 AJAX 调用,只有处理成功 AJAX 返回的函数:

// ajax successful return function 
// this function is our success function passed to our jquery AJAX call
// data is the assets array encoded in JSON string
function(result,message,data)
{
loadTree(data); 
});

谁能告诉我为什么这棵树在初始加载时完美排序,但是在平面视图中加载时,树本身按名称完美排序,但单击列标题不会产生明显的变化?

以下是在平面视图中加载资产时 AJAX 提交返回的完整 JSON:

{"result":"Success","message":"","data":[{"id":"86","parentid":"220","aname":"Acer Aspire","aid":"643","did":"505","pcondition":"n","pdescription":"Acer Aspire 5742-6331 15in Laptop","pdate":"06/30/2012","pcost":"481.49","pvendor":"St.Pete College","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Jocelyn Home","adescription":"Acer Aspire Laptop (Jocelyn)","apo":"","asn":"LXR4F0248114807C7B1601","awdate":"","anotes":"Transaction GID: 135761","childCount":"0","a_account":"17600: Computers, Printers, Accessories","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"220","level":0,"isLeaf":true},{"id":"18","parentid":"38","aname":"APC Battery Back-Up UPS","aid":"649","did":"505","pcondition":"u","pdescription":"APC Smart UPS 1500","pdate":"06/30/2012","pcost":"300.00","pvendor":"Craigslist","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"APC 4-Post Rack","adescription":"APC Smart UPS 1500 (SUA1500RM2U)","apo":"","asn":"AS0414112240","awdate":"","anotes":"Transaction GID: 135759","childCount":"0","a_account":"17700: Networking Equipment","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"38","level":0,"isLeaf":true},{"id":"213","parentid":"38","aname":"APC Battery Back-Up UPS","aid":"649","did":"505","pcondition":"u","pdescription":"APC Smart UPS 1500","pdate":"06/30/2012","pcost":"300.00","pvendor":"Craigslist","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"APC 4-Post Rack","adescription":"APC Smart UPS 1500 (SUA1500RM2U)","apo":"","asn":"AS041411210","awdate":"","anotes":"Transaction GID: 135759","childCount":"0","a_account":"17700: Networking Equipment","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"38","level":0,"isLeaf":true},{"id":"214","parentid":"38","aname":"APC Battery Back-Up UPS","aid":"649","did":"505","pcondition":"u","pdescription":"APC Smart UPS 1500","pdate":"06/30/2012","pcost":"300.00","pvendor":"Craigslist","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"APC 4-Post Rack","adescription":"APC Smart UPS 1500 (SUA1500RM2U)","apo":"","asn":"AS0414211674","awdate":"","anotes":"Transaction GID: 135759","childCount":"0","a_account":"17700: Networking Equipment","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"38","level":0,"isLeaf":true},{"id":"95","parentid":"219","aname":"Apple iMac 24","aid":"643","did":"505","pcondition":"u","pdescription":"Apple 24in iMac ","pdate":"06/30/2012","pcost":"1200.00","pvendor":"Jamilou Rosenkrans (Labor Trade Chance)","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Tech Area","adescription":"Apple 24in iMac ","apo":"","asn":"W87350BDZCV","awdate":"","anotes":"Transaction GID: 135763n2.8GHz, 2GB RAM, 500GB HDD","childCount":"0","a_account":"17600: Computers, Printers, Accessories","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"219","level":0,"isLeaf":true},{"id":"206","parentid":"220","aname":"Apple iPad 2","aid":"643","did":"505","pcondition":"u","pdescription":"Apple iPad 2 16GB, Wi-Fi, 9.7in - Black (MC769LL/A)","pdate":"05/18/2015","pcost":"189.99","pvendor":"eBay: eric9730, eBay: likenewproduct","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Jocelyn Home","adescription":"Apple iPad 2 16GB, Wi-Fi, 9.7in - Black  (Jocelyn)","apo":"","asn":"DYVJK5LWDFHW","awdate":"","anotes":"Transaction GID: 653397, iPad, $170.00nTransaction GID: 653393, Portfolio, $19.99","childCount":"0","a_account":"17600: Computers, Printers, Accessories","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"220","level":0,"isLeaf":true},{"id":"6","parentid":"222","aname":"Astro Van","aid":"633","did":"505","pcondition":"u","pdescription":"2004 Chevy Astro","pdate":"08/14/2008","pcost":"8342.15","pvendor":"TMJ Enterprises","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"3135 Office","adescription":"2004 Chevy Astro","apo":"","asn":"1234567890","awdate":"","anotes":"Transaction GID: 135743","childCount":"0","a_account":"17500: 2004 Chevy Astro","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"222","level":0,"isLeaf":true},{"id":"19","parentid":"38","aname":"Belkin LCD Console","aid":"649","did":"505","pcondition":"u","pdescription":"Belkin 15in 1U Rackmount KVM Console","pdate":"12/29/2011","pcost":"218.03","pvendor":"eBay: techforless","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"APC 4-Post Rack","adescription":"Belkin 15in 1U Rackmount KVM Console","apo":"","asn":"471001000121","awdate":"","anotes":"Transaction GID: 672437","childCount":"0","a_account":"17700: Networking Equipment","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"38","level":0,"isLeaf":true},{"id":"54","parentid":"216","aname":"Black/Silver Office Chairs (Qty 4)","aid":"412","did":"505","pcondition":"n","pdescription":"4 Black Leather and Silver Metal Office Chairs","pdate":"02/06/2013","pcost":"310.00","pvendor":"Fay Marakas","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Lobby and Office","adescription":"4 Black Leather and Silver Metal Office Chairs","apo":"","asn":"n/a","awdate":"","anotes":"Transaction GID: 132468","childCount":"0","a_account":"17200: Office Furniture","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"216","level":0,"isLeaf":true},{"id":"17","parentid":"219","aname":"Cisco 24-Port Switch","aid":"649","did":"505","pcondition":"u","pdescription":"PoE Cisco Catalyst 3550 WS-C3550-24PS-S","pdate":"11/14/2011","pcost":"300.00","pvendor":"Vology","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Tech","adescription":"Cisco 3550 24-Port PoE Switch","apo":"","asn":"CAT0723Z190","awdate":"","anotes":"Transaction GID: 91077","childCount":"0","a_account":"17700: Networking Equipment","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"219","level":0,"isLeaf":true},{"id":"205","parentid":"38","aname":"Cisco 48-Port Switch","aid":"649","did":"505","pcondition":"u","pdescription":"PoE Cisco Catalyst 3750 WS-C3750-48PS-S","pdate":"02/19/2015","pcost":"695.00","pvendor":"Vology","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Rack","adescription":"Cisco 3750 48-Port PoE Switch","apo":"BS021915","asn":"FDO1338X1G4","awdate":"","anotes":"Transaction GID: 654330","childCount":"0","a_account":"17700: Networking Equipment","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"38","level":0,"isLeaf":true},{"id":"44","parentid":"215","aname":"Danby Refrigerator","aid":"407","did":"505","pcondition":"n","pdescription":"10cu.ft. Upright Refrigerator","pdate":"02/05/2013","pcost":"400.44","pvendor":"HHGregg","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"3135 Kitchen","adescription":"10cu.ft. Upright Refrigerator","apo":"","asn":"123456789","awdate":"","anotes":"Transaction GID: 120592","childCount":"0","a_account":"17100: Office Equipment","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"215","level":0,"isLeaf":true},{"id":"49","parentid":"222","aname":"Dell Inspiron","aid":"643","did":"505","pcondition":"n","pdescription":"Dell Inpiron 17in Laptop","pdate":"08/02/2013","pcost":"630.49","pvendor":"Dell","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Chance Home","adescription":"Dell Inspiron 17in Laptop (Chance)","apo":"","asn":"65YVPX1","awdate":"","anotes":"Transaction GID: 134554nPurchase Order #: BS080213","childCount":"0","a_account":"17600: Computers, Printers, Accessories","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"222","level":0,"isLeaf":true},{"id":"200","parentid":"218","aname":"Dell Optiplex 3010","aid":"643","did":"505","pcondition":"u","pdescription":"Dell Optiplex 3010","pdate":"03/01/2018","pcost":"300.00","pvendor":"Safety Harbor Professional","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Chance desk","adescription":"Dell Optiplex 3010 (Chance)","apo":"","asn":"BGTYNW1","awdate":"","anotes":"Acquired from SHP unti #8 in exchange for multiple services (see contract with SHP)nTranaction GID:715683, 715602","childCount":"0","a_account":"17600: Computers, Printers, Accessories","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"218","level":0,"isLeaf":true},{"id":"201","parentid":"218","aname":"Dell Optiplex 3040","aid":"643","did":"505","pcondition":"n","pdescription":"Dell Optiplex 3040 SFF","pdate":"08/30/2016","pcost":"602.39","pvendor":"Dell","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Deneen desk","adescription":"Dell Optiplex 3040 (Deneen)","apo":"BS083016","asn":"FSW4DD2","awdate":"","anotes":"Transaction GID: 669351","childCount":"0","a_account":"17600: Computers, Printers, Accessories","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"218","level":0,"isLeaf":true},{"id":"28","parentid":"38","aname":"Dell PowerEdge R300 Server","aid":"649","did":"505","pcondition":"u","pdescription":"Dell PowerEdge R300 Server","pdate":"03/03/2012","pcost":"500.00","pvendor":"Craigslist","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"APC 4-Post Rack","adescription":"Dell PowerEdge R300 Server","apo":"","asn":"123456789","awdate":"","anotes":"","childCount":"0","a_account":"17700: Networking Equipment","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"38","level":0,"isLeaf":true},{"id":"30","parentid":"221","aname":"Dewalt Air Compressor","aid":"646","did":"505","pcondition":"n","pdescription":"Dewalt 2-Gallon Air Compressor","pdate":"12/11/2012","pcost":"423.68","pvendor":"HomeDepot","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Chance Home","adescription":"Dewalt 2-Gallon Air Compressor","apo":"","asn":"123456789","awdate":"","anotes":"Transaction GID: 95704","childCount":"0","a_account":"17950: Tools","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"221","level":0,"isLeaf":true},{"id":"57","parentid":"216","aname":"Display Case","aid":"412","did":"505","pcondition":"u","pdescription":"Point-of-Sale Display Case and Shelving","pdate":"03/06/2013","pcost":"867.54","pvendor":"Craigslist/U-Haul/Owner","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"3135 Lobby","adescription":"Point-of-Sale Display Case and Shelving","apo":"","asn":"n/a","awdate":"","anotes":"Owner Contribution: $350.00nTransaction GID: 97143 $400.00 ATMnTransaction GID: 97139 $117.54 U-Haul","childCount":"0","a_account":"17200: Office Furniture","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"216","level":0,"isLeaf":true},{"id":"202","parentid":"216","aname":"Eclipse NVR System","aid":"407","did":"505","pcondition":"n","pdescription":"Signature 8CH H.265, H.264 NVR","pdate":"06/15/2018","pcost":"437.60","pvendor":"Eclipse","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"3135 office","adescription":"Signature 8CH H.265, H.264 NVR, with qty 4 2MP 3.6MM Bullet Cameras","apo":"BS061318","asn":"T3D93185000428","awdate":"","anotes":"Cameras:nS/N: T3WHA181000009nS/N: T3WHA181000287nS/N: T3WHA181000289nS/N: T3WHA181000480","childCount":"0","a_account":"17100: Office Equipment","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"216","level":0,"isLeaf":true},{"id":"199","parentid":"222","aname":"Garmin GPS","aid":"461","did":"505","pcondition":"n","pdescription":"Garmin nuvi 2555LMT","pdate":"02/24/2013","pcost":"211.86","pvendor":"Walmart","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"2004 Chevy Astro","adescription":"Garmin nuvi 2555LMT","apo":"","asn":"2LQ229023","awdate":"","anotes":"Transaction GID:96521","childCount":"0","a_account":"17300: Mobile Repair Units","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"222","level":0,"isLeaf":true},{"id":"203","parentid":"216","aname":"Kobalt 3-Gallon Air Compressor","aid":"646","did":"505","pcondition":"n","pdescription":"Kobalt 3-Gallon Air Compressor","pdate":"11/10/2013","pcost":"167.06","pvendor":"Lowes","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Lobby","adescription":"Kobalt 3-Gallon Air Compressor","apo":"","asn":"n/a","awdate":"","anotes":"Transaction GID: 136657, 25ft Air Hose/Couplings, $29.03nTransaction GID: 137512, Compressor, $98.03 + $40.00 = $138.03","childCount":"0","a_account":"17950: Tools","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"216","level":0,"isLeaf":true},{"id":"85","parentid":"218","aname":"Lateral File Cabinet (4-Drawer)","aid":"412","did":"505","pcondition":"u","pdescription":"HON 4-Drawer Lateral File Cabinet","pdate":"06/30/2011","pcost":"300.00","pvendor":"Exec Inc Real Estate (Labor Trade Chance)","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Office","adescription":"HON 4-Drawer Lateral File Cabinet","apo":"","asn":"n/a","awdate":"","anotes":"Transaction GID: 135753","childCount":"0","a_account":"17200: Office Furniture","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"218","level":0,"isLeaf":true},{"id":"204","parentid":"218","aname":"MFC 9460CDN AIO","aid":"643","did":"505","pcondition":"n","pdescription":"Brother MFC-9460CDN Printer/Scanner/Fax","pdate":"03/05/2014","pcost":"513.59","pvendor":"Office Depot","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Office","adescription":"Brother MFC-9460CDN Printer/Scanner/Fax","apo":"","asn":"U62511-B2J284710","awdate":"","anotes":"Transaction GID: 148148","childCount":"0","a_account":"17600: Computers, Printers, Accessories","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"218","level":0,"isLeaf":true},{"id":"64","parentid":"216","aname":"Plexiglass Logo","aid":"412","did":"505","pcondition":"n","pdescription":"Company Logo and Lettering on custom plexiglass","pdate":"08/31/2013","pcost":"382.75","pvendor":"ASAP Signs &amp; Graphics","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Lobby","adescription":"Plexiglass Logo","apo":"","asn":"n/a","awdate":"","anotes":"Transaction GID: 678791","childCount":"0","a_account":"17200: Office Furniture","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"216","level":0,"isLeaf":true},{"id":"7","parentid":"217","aname":"Quadro 2x IP-PBX","aid":"650","did":"505","pcondition":"u","pdescription":"Epygi Quadro 2x","pdate":"02/28/2010","pcost":"117.45","pvendor":"eBay: darin_ext@darinsmith.net","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Lockup","adescription":"Epygi Quadro 2x","apo":"","asn":"132342810461","awdate":"","anotes":"Transaction GID: 670503","childCount":"0","a_account":"17800: Telephony Equipment","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"217","level":0,"isLeaf":true},{"id":"43","parentid":"217","aname":"Quadro 4x IP-PBX","aid":"650","did":"505","pcondition":"u","pdescription":"Epygi Quadro 4x","pdate":"01/07/2013","pcost":"255.00","pvendor":"eBay: totalcomsolutions","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Lockup","adescription":"Epygi Quadro 4x","apo":"","asn":"132342189559","awdate":"","anotes":"Transaction GID: 673414","childCount":"0","a_account":"17800: Telephony Equipment","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"217","level":0,"isLeaf":true},{"id":"207","parentid":"38","aname":"QX50 IP PBX","aid":"650","did":"505","pcondition":"n","pdescription":"Epygi QX50 IP-PBX","pdate":"11/04/2015","pcost":"725.80","pvendor":"Alloy CP","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"APC 4-Post Rack","adescription":"Epygi QX50 IP-PBX","apo":"","asn":"232344221779","awdate":"","anotes":"Transaction GID: 660454","childCount":"0","a_account":"17800: Telephony Equipment","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"38","level":0,"isLeaf":true},{"id":"211","parentid":"221","aname":"Ridgid Belt Sander","aid":"646","did":"505","pcondition":"n","pdescription":"Ridgid 3-inch Belt Sander (R2740)","pdate":"01/22/2017","pcost":"63.00","pvendor":"Home Depot","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Chance Home","adescription":"Ridgid 3-inch Belt Sander","apo":"","asn":"CS16383ND13125","awdate":"","anotes":"Transaction GID: 679052","childCount":"0","a_account":"17950: Tools","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"221","level":0,"isLeaf":true},{"id":"210","parentid":"221","aname":"Ridgid Hammer Drill","aid":"646","did":"505","pcondition":"n","pdescription":"Ridgid 18v 1/2-inch Brushless Hammer Drill (R86116K)","pdate":"04/19/2016","pcost":"191.53","pvendor":"Home Depot","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Chance Home","adescription":"Ridgid 1/2-inch 18v Hammer Drill","apo":"","asn":"CS16055DA90189","awdate":"","anotes":"Transaction GID: 666298","childCount":"0","a_account":"17950: Tools","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"221","level":0,"isLeaf":true},{"id":"32","parentid":"221","aname":"Ridgid Miter Saw","aid":"646","did":"505","pcondition":"n","pdescription":"Ridgid 12inch Compound Miter Saw (R4120)","pdate":"12/11/2012","pcost":"318.04","pvendor":"HomeDepot","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Chance Home","adescription":"Ridgid 12-inch Compound Miter Saw","apo":"","asn":"Z1230 62009","awdate":"","anotes":"Transaction GID: 95704","childCount":"0","a_account":"17950: Tools","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"221","level":0,"isLeaf":true},{"id":"209","parentid":"221","aname":"Ridgid Nail Gun","aid":"646","did":"505","pcondition":"n","pdescription":"Ridgid 1/8in Brad Nailer (R213BNE)","pdate":"07/12/2014","pcost":"104.86","pvendor":"Home Depot","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Chance Home","adescription":"Ridgid 1/8-inch Brad Nail Gun","apo":"","asn":"AW140738204","awdate":"","anotes":"Transaction GID: 428101","childCount":"0","a_account":"17950: Tools","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"221","level":0,"isLeaf":true},{"id":"212","parentid":"221","aname":"Ridgid Radio","aid":"646","did":"505","pcondition":"n","pdescription":"Ridgid 18v Mini-Radio (R84084)","pdate":"04/19/2016","pcost":"42.77","pvendor":"Home Depot","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Chance Home","adescription":"Ridgid 18v Radio","apo":"","asn":"CA15475D018919","awdate":"","anotes":"Transaction GID: 666298","childCount":"0","a_account":"17950: Tools","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"221","level":0,"isLeaf":true},{"id":"31","parentid":"221","aname":"Ridgid Table Saw","aid":"646","did":"505","pcondition":"n","pdescription":"Ridgid 10inch Table Saw (R45101)","pdate":"12/11/2012","pcost":"599.99","pvendor":"HomeDepot","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Chance Home","adescription":"Ridgid 10-inch Table Saw","apo":"","asn":"Z1234 13905","awdate":"","anotes":"Transaction GID: 95704","childCount":"0","a_account":"17950: Tools","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"221","level":0,"isLeaf":true},{"id":"208","parentid":"218","aname":"SIPT29G IP-PHONE (Qty 3)","aid":"650","did":"505","pcondition":"n","pdescription":"Yealink SIP-T29G IP Phone","pdate":"11/04/2015","pcost":"355.20","pvendor":"Alloy CP","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Office/Lobby/Tech","adescription":"Yealink SIP-T29G IP Phone","apo":"","asn":"8129215030201450, 8129215030201451, 8129215030201452","awdate":"","anotes":"Transaction GID: 660454","childCount":"0","a_account":"17800: Telephony Equipment","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"218","level":0,"isLeaf":true},{"id":"1","parentid":"223","aname":"TomTom One XL GPS","aid":"461","did":"505","pcondition":"n","pdescription":"TomTom One XL","pdate":"03/22/2009","pcost":"124.99","pvendor":"eBay: eshopic","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"2004 Chevy Astro","adescription":"TomTom One XL","apo":"","asn":"1234567890","awdate":"","anotes":"u00a0Transaction GID: 670696","childCount":"0","a_account":"17300: Mobile Repair Units","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"223","level":0,"isLeaf":true},{"id":"24","parentid":"216","aname":"Wall Shelving Unit","aid":"412","did":"505","pcondition":"n","pdescription":"Cabinets and shelving joined into single wall unit","pdate":"02/06/2012","pcost":"379.43","pvendor":"Home Depot","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Lobby","adescription":"Wall Shelving Unit","apo":"","asn":"n/a","awdate":"","anotes":"Transaction GID: 91925, Original 24inch cabinets, $188.15nTransaction GID: 667201, Miscellaneous wood shelving and supports to combine cabinets together across tech-wall windown","childCount":"0","a_account":"17200: Office Furniture","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"216","level":0,"isLeaf":true},{"id":"33","parentid":"219","aname":"Workbench","aid":"412","did":"505","pcondition":"n","pdescription":"Miscellaneous components and materials to build u-shaped workbench and workbech island","pdate":"06/01/2013","pcost":"754.25","pvendor":"Home Depot/Walmart","ssold":"n","sdescription":"","sdate":"","sprice":"0.00","sexpense":"0.00","alocation":"Tech","adescription":"Tech Area Workbench &amp; Island","apo":"","asn":"n/a","awdate":"","anotes":"Transaction GID: 135773,96311,96542,96572,96646,96801,96823,96893,130251,130071,130082,677974,132491,132493,132497,133240,667352","childCount":"0","a_account":"17200: Office Furniture","d_account":"17999: Accumulated Depreciation","loaded":true,"parent":"219","level":0,"isLeaf":true}]}

实际上,在检查返回的 AJAX 数据后,我找到了自己的答案。

在分组模式下加载时,服务器返回包含名为"parent"的字段的节点,该字段包含父节点的 ID。 树网格使用此字段来了解如何将节点正确分组到彼此之下。

在"平面视图"模式下加载时,服务器端代码包含设置为正确父级的相同"父"字段,但服务器在返回中排除了实际的父节点。由于某些节点指向不存在的父节点,因此树网格无法应用排序。

但是现在,"parent"字段在"平面视图"结果中返回为 null,树网格对所有列进行正确排序,因为它看起来不会先于其他列对父列进行排序。

最新更新