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

FEATURE: Allow access to properties that are deeper down the object tree #81

Conversation

dtchau
Copy link
Contributor

@dtchau dtchau commented Mar 12, 2016

The current implementation only allows the user to access a row's first-level properties.

For example, if you have some underlying objects that look like this

let students = [
  {name: 'ABC', address: {number: 123, street: ABC Street'}, phones: [{type: 'cell', number: 123456789}]},
  {name: 'XYZ', address: {number: 456, street: 'XYZ Street'}, phones: [{type: 'cell', number: 123456789}]}
];

and you want to display the street on the table, you will first have to map them to something like this

let rows = students.map(student => {
  return {name: student.name, addressNumber: student.address.number, addressStreet: student.address.street};
})

before you can assign this to ngTable's rows input. It's because rows[0]['address.number'] will return undefined.

I propose we allow users to access properties that are deeper than the first-level properties.

For example, to display the street name, one can simply set the column.name to 'address.street'. This notation will work for array too. For example, to show the first phone number, just set column.name to 'phones.0.number'.

@valorkin
Copy link
Member

Looks great!

@valorkin valorkin merged commit b7de4ad into valor-software:master Apr 11, 2016
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

Successfully merging this pull request may close these issues.

2 participants