Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access object properties #136

Open
SoftCreatR opened this issue Apr 2, 2017 · 5 comments
Open

Access object properties #136

SoftCreatR opened this issue Apr 2, 2017 · 5 comments

Comments

@SoftCreatR
Copy link

Hi,

the objects i use to generate the table contain sub objects e.g.

"foo":{"bar":"baz","x":"y"}

I try to access the property bar from this object:

{
        field: "foo.bar",
        displayName: "Foo Bar"
}

However, that doesn't work for some reason. It doesn't display anything. But if i do

{
        field: "foo",
        displayName: "Foo Bar"
}

it displays:

{"bar":"baz","x":"y"}

How can i get around that without changing the format of the JSON?

@torsten-sauer
Copy link

The field property isn't designed to be used for deep object traversal - it is simply the name of the property of the node.

You have two options I would say:

  1. you can "flatten" your nodes and construct a simple object
  2. you can define a cellTemplate for your node where you can access everythin from your object

@SoftCreatR
Copy link
Author

Flattening is a bad idea imho, if you have a large set of nodes. Interestingly, i can't make the cellTemplate approach work.

@torsten-sauer
Copy link

What are you concrete problems with the cellTemplate?

Inside the template you can access your node via row.branch. That gives you the single node.

Shortened Example:

...
cellTemplate: "<span>{{row.branch.foo.bar}}</span>",
...

@SoftCreatR
Copy link
Author

Ah, that did the trick. I was missing the surrounding span, so all i got was an error.

Thank you :)

@torsten-sauer
Copy link

Yeah, you need one html element to let angular render the whole thing - otherwise it complains ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants