Reputation: 45
I have a jqGrid TreeGrid that I load from server sorted just fine, where the nodes contain assets (leafs). Some of the assets are grouped into assemblies where those nodes are expandable. When the tree first loads, the tree looks perfect and sorts properly across all nodes. All leaf nodes are exactly as they should be and the lower-level leaf nodes also sort accordingly with the parent nodes, across whatever sortable column header is clicked.
But I also allow the user to load the tree in "flat view" with no grouping. The tree loads again from server already sorted according to the first column. Flat view removes the assembly layout and returns all assets as leafs. The tree contains all nodes in perfect order as presented by server. But in "flat view" the tree no longer sorts at all by clicking any of the sortable column headers. So, something with my code is most likely not defined properly.
Here is the TreeGrid Creation Code (using version 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
});
And the server side PHP function that gets the assets from DB:
// 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;
}
And the javascript function that loads the tree with the assets:
// 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');
}
To initially load the tree on page load, we use php to get the assets into an array in grouping mode, encode that to JSON using php json_encode(), then we embed the call to loadTree($assets) on the document.ready() event as follows:
echo("\n
$(document).on('ready', function()\n
{\n
// load the tree\n
loadTree({$assets});\n
});\n
";
When user wants to change from group view to flat view, an ajax request is sent to server and the resultant assets returned in JSON encoded string is then passed to same loadTree(assets) javascript function. The AJAX invocation is not present here, just the function that handles the successful AJAX return:
// 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);
});
Can anyone tell me why this tree sorts perfectly on initial load, but when loaded in flat view, the tree itself is sorted by name perfectly, but clicking the column headers makes no visible change?
Here is the full JSON returned by the AJAX submission when loading assets in flat view:
{"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: 135763\n2.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.00\nTransaction 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: 134554\nPurchase 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.00\nTransaction GID: 97143 $400.00 ATM\nTransaction 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: T3WHA181000009\nS\/N: T3WHA181000287\nS\/N: T3WHA181000289\nS\/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.03\nTransaction 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 & 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: [email protected]","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.15\nTransaction GID: 667201, Miscellaneous wood shelving and supports to combine cabinets together across tech-wall window\n","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 & 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}]}
Upvotes: 0
Views: 167
Reputation: 45
I actually found my own answer following the examination of the returned AJAX data.
When loading in grouped mode, the server returns nodes containing the field named "parent" that contains the ID of the parent node. The treegrid uses this field for knowing how to group the nodes under each other properly.
When loading in "flat view" mode, the server-side code was including this same "parent" field set to the proper parent, but the server was excluding the actual parent nodes in the return. Because some node(s) pointed to non-existent parent nodes, the treegrid was not able to apply sorting.
But now that the "parent" field is returned as null with the "flat view" results, the treegrid sorts properly on all columns as it should because it does not look to sort parents before others.
Upvotes: 0