khan4019 / tree-grid-directive

Need one or more maintainer for this! comment or email me if you are interested
http://khan4019.github.io/tree-grid-directive/test/treeGrid.html
347 stars 183 forks source link

How can you dynamically add/remove colums? #66

Closed sdimagno closed 8 years ago

sdimagno commented 8 years ago

In my tree-grid, the child nodes have additional columns. If any of the children are expanded, I want to have the extra columns added. I tried to update the columns on click like so:

    function updateColDefs(expanded) {
        var cols = expanded ? $scope.col_defs_expanded : $scope.col_defs;
        $scope.columns = [];
        cols.forEach(function(c) {
            $scope.columns.push(c);
        });
    };

But this doesn't seem to change the view.

cray2015 commented 8 years ago

Just add a watch in the JS file like below: scope.$watch('colDefs', function (newValue, oldValue) { if (newValue != oldValue) { scope.colDefinitions = scope.colDefs; } });

TrueDub commented 8 years ago

Assuming this is answered.