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

Last column Appearing Twice #68

Closed locus2k closed 8 years ago

locus2k commented 8 years ago

Hello,

I am trying to create dynamic tree-grid information and for some reason the last column is appearing twice as the first and last column and is ignoring what I have actually as the first and last column.

This is how I have it setup:

$scope.treeData = [];

$scope.colDefs = [ {field: "Answered", displayName: "Answered"}, {field: "Total", displayName: "Total"}, {field: "Percentage", displayName: "Percentage"} ];

$scope.updateTreeData = function() { console.log('Updating tree data', true); $scope.treeData = [];

        for (var i = 0; i < $scope.quesnrList.length; i++) {
            var quesnr = $scope.quesnrList[i];
            var quesnrName = quesnr.Name;
            var answered = 0;
            var total = 0;

            for (var j = 0; j < quesnr.detailedQuestions.length; j++) {
                var detailedQuestion = quesnr.detailedQuestions[j];
                for (var k = 0; k < detailedQuestion.questions.length; k++) {
                    var question = detailedQuestion.questions[k];
                    console.log("Question=", question);
                    total += 1;
                    if (question.selectedAnswer.answered) {
                        answered += 1;
                    }
                }
            }

            $scope.treeData.push(
                    {
                        Name: quesnrName,
                        Answered: answered,
                        Total: total,
                        Percentage: ((answered/total) * 100) + '%'
                    }
            );
        }
         };

has anyone else experienced this issue?

locus2k commented 8 years ago

I figured out. I wasnt passing in the expanding property or giving it the name. After doing so, it worked fine