diff --git a/src/tree-grid-directive.js b/src/tree-grid-directive.js index 08d514b..18a02e6 100644 --- a/src/tree-grid-directive.js +++ b/src/tree-grid-directive.js @@ -16,7 +16,7 @@ " \n" + " \n" + - " " + @@ -72,7 +72,7 @@ '$timeout', 'treegridTemplate', function ($timeout, - treegridTemplate) { + treegridTemplate) { return { restrict: 'E', @@ -102,8 +102,9 @@ attrs.iconExpand = attrs.iconExpand ? attrs.iconExpand : 'icon-plus glyphicon glyphicon-plus fa fa-plus'; attrs.iconCollapse = attrs.iconCollapse ? attrs.iconCollapse : 'icon-minus glyphicon glyphicon-minus fa fa-minus'; attrs.iconLeaf = attrs.iconLeaf ? attrs.iconLeaf : 'icon-file glyphicon glyphicon-file fa fa-file'; - attrs.sortedAsc = attrs.sortedAsc ? attrs.sortedAsc : 'icon-file glyphicon glyphicon-chevron-up fa angle-up'; - attrs.sortedDesc = attrs.sortedDesc ? attrs.sortedDesc : 'icon-file glyphicon glyphicon-chevron-down fa angle-down'; + attrs.iconRoot = attrs.iconRoot ? attrs.iconRoot : ''; + attrs.sortedAsc = attrs.sortedAsc ? attrs.sortedAsc : 'icon-file glyphicon glyphicon-chevron-up fa fa-angle-up'; + attrs.sortedDesc = attrs.sortedDesc ? attrs.sortedDesc : 'icon-file glyphicon glyphicon-chevron-down fa fa-angle-down'; attrs.expandLevel = attrs.expandLevel ? attrs.expandLevel : '0'; expand_level = parseInt(attrs.expandLevel, 10); @@ -282,6 +283,11 @@ col.sortDirection = "none"; } } + // Reset sorting on expanding column + if (scope.expandingProperty && scope.expandingProperty.field != sortedCol.field) { + scope.expandingProperty.sorted = false; + scope.expandingProperty.sortDirection = 'none'; + } } /* end of sorting methods */ @@ -371,7 +377,11 @@ branch.expanded = false; } if (!branch.children || branch.children.length === 0) { - tree_icon = branch.icons && branch.icons.iconLeaf || attrs.iconLeaf; + if ((branch.icons && branch.icons.iconRoot || attrs.iconRoot) && branch.parent_uid == null) { + tree_icon = branch.icons && branch.icons.iconRoot || attrs.iconRoot; + } else { + tree_icon = branch.icons && branch.icons.iconLeaf || attrs.iconLeaf; + } } else { if (branch.expanded) { tree_icon = branch.icons && branch.icons.iconCollapse || attrs.iconCollapse;