0

In my first angular app i have such data:

tree_rows = [{"level":1,"branch":{"Name":"USA","Area":9826675,"Population":318212000,"TimeZone":"UTC -5 to -10","children":[{"Name":"California","Area":423970,"Population":38340000,"TimeZone":"Pacific Time","children":[{"Name":"San Francisco","Area":231,"Population":837442,"TimeZone":"PST"},{"Name":"Los Angeles","Area":503,"Population":3904657,"TimeZone":"PST"}]},{"Name":"Illinois","Area":57914,"Population":12882135,"TimeZone":"Central Time Zone","children":[{"Name":"Chicago","Area":234,"Population":2695598,"TimeZone":"CST"}]}],"level":1,"expanded":true,"uid":"0.5810681234579533","Options":[]},"label":"USA","tree_icon":"icon-file glyphicon glyphicon-file fa fa-file","visible":true},{"level":1,"branch":{"Name":"Texas","Area":268581,"Population":26448193,"TimeZone":"Mountain","level":1,"expanded":true,"uid":"0.8260199765209109","Options":[]},"label":"Texas","tree_icon":"icon-file glyphicon glyphicon-file fa fa-file","visible":true}]

colDefinitions = [{"field":"Area"},{"field":"Population"},{"field":"TimeZone"},{"field":"children"}]

and i try to view it via table-grid-view:

<tr ng-repeat=\"row in tree_rows | filter:{visible:true} track by row.branch.uid\"
            ng-class=\"'level-' + {{ row.level }} + (row.branch.selected ? ' active':'')\" class=\"tree-grid-row\">
            <td class=\"text-primary\"><a ng-click=\"user_clicks_branch(row.branch)\"><i ng-class=\"row.tree_icon\"
                       ng-click=\"row.branch.expanded = !row.branch.expanded\"
                       class=\"indented tree-icon\"></i>
                </a><span class=\"indented tree-label\" ng-click=\"user_clicks_branch(row.branch)\">
                  {{row.branch[expandingProperty]}}</span>
            </td>
            <td ng-repeat=\"col in colDefinitions\">{{row.branch[col.field]}}</td> - this line!!!
</tr>

and all is ok, just that i want to display not all data as: <td ng-repeat=\"col in colDefinitions\">{{row.branch[col.field]}}</td> but for example {{row.branch[Name]}} , {{row.branch[Population]}} and there i didn't see any data. But why?

How to get data from my array via field?

ps: i use this: https://github.com/khan4019/tree-grid-directive/blob/master/README.md

8
  • please paste your code in plnkr.co Commented Dec 24, 2014 at 13:28
  • It hard to guess as it could be a lot of things until you share your code anywhere. First of all, I will not recommend this tree directive as first thing to try for angular. there are tons of beginner tutorials online for angular. However, if you want to try this tree directive, go to this demo link: khan4019.github.io/tree-grid-directive/test/treeGrid.html get treeGridTest.js and treeGrid.html and other libraries and play with it...and then place your data in the code and go from there... Commented Dec 24, 2014 at 14:31
  • @KhanSharp my code is this directive... all this is based on your link Commented Dec 24, 2014 at 20:34
  • @KhanSharp how from this plugin display only specific fields? Commented Dec 25, 2014 at 16:13
  • by using the column definition Commented Dec 25, 2014 at 16:57

1 Answer 1

1

Try {{row.branch["Name"]}} instead, quoting the field name

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.