Return current row value of a Tree-grid-Directive tree

Asked

Viewed 82 times

0

I’m using the Tree-grid-Directive (https://github.com/khan4019/tree-grid-directive) in an Angularjs application and would like to know how to return the object representing the current row in the tree.

For example, I have the following column definition:

$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 clicking the button, it pass as parameter to the ng-click function the value of the line that is the button.

Thanks in advance!

1 answer

0


Checking the source code, I discovered that by passing the parameter "Row.branch" in the function, it returns the line object.

For example, pass 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
                    }
                }
            }];

Browser other questions tagged

You are not signed in. Login or sign up in order to post.