From 34b7c1003b87a29a174994a85c83e8bbc76e9c10 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Mon, 8 Mar 2021 11:20:50 +0100 Subject: [PATCH] Fixed error with sorting --- .../include/javascript/tree/TreeController.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 38e9e7cedd..ee8de7a5d9 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -1077,13 +1077,16 @@ var TreeController = { var rawTree = Object.values(data.tree); // Sorting tree by description (services.treeview_services.php). rawTree.sort(function(a, b) { - var x = a.elementDescription.toLowerCase(); - var y = b.elementDescription.toLowerCase(); - if (x < y) { - return -1; - } - if (x > y) { - return 1; + // Only the services are ordered since only they have the elementDescription property. + if (a.elementDescription && b.elementDescription) { + var x = a.elementDescription.toLowerCase(); + var y = b.elementDescription.toLowerCase(); + if (x < y) { + return -1; + } + if (x > y) { + return 1; + } } return 0; });