Return value of the current row of a tree of the directive tree-grid-directive

0

I'm using the tree-grid-directive ( link ) in an angularJS application and would like to know how to return the object that represents the current row in the tree.

For example, I have the following definition of columns:

$scope.col_defs = [
            { 
                field: "Nome" 
            }, 
            {
                field: "Ação",
                cellTemplate: $templateCache.get('botoesTree.html'),
                cellTemplateScope: {
                    executar: function () {
                       // Onde gostaria de receber o valor do registro 
                       // atual(no caso clicado) da árvore
                        executar();
                    }
                }
            }];

And in the view I have the following code:

 <script type="text/ng-template" id="botoesTree.html">                        
            <button class="btn btn-sm btn-danger" ng-click="cellTemplateScope.executar()">Excluir</button>
</script>

I would like when I click the button, it passes as parameter to the function of the ng-click the value of the line that is the button.

Thank you in advance!

    
asked by anonymous 02.12.2016 / 17:43

1 answer

0

By checking the source code, I discovered that by passing the "row.branch" parameter in the function, it returns the line object.

For example would pass the row.branch to the function:

<script type="text/ng-template" id="botoesTree.html">                        
            <button class="btn btn-sm btn-danger" ng-click="cellTemplateScope.executar(row.branch)">Excluir</button>
</script>

And it returns me the object representing the line, in the function:

$scope.col_defs = [
            { 
                field: "Nome" 
            }, 
            {
                field: "Ação",
                cellTemplate: $templateCache.get('botoesTree.html'),
                cellTemplateScope: {
                    executar: function (objeto) {
                       // O objeto é no caso retornaria o objeto da linha da árvore
                    }
                }
            }];
    
02.12.2016 / 20:48