From 5b250b02fe6e536861384c1cb74d5f25fa551b3e Mon Sep 17 00:00:00 2001 From: Sebastian Frank Date: Fri, 25 Aug 2017 13:28:57 +0200 Subject: [PATCH] table column with subobjects --- src/components/my-table.vue | 12 +++++++++++- src/components/userlist.vue | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/my-table.vue b/src/components/my-table.vue index 7d385b0..5a41a79 100644 --- a/src/components/my-table.vue +++ b/src/components/my-table.vue @@ -13,7 +13,7 @@ - {{ r[c.prop] }} + {{ getProp(r, c.prop) }} {{ c.render(r) }} @@ -51,6 +51,16 @@ export default { orderBy: col, orderDesc: false }); + }, + getProp(row, prop) { + let props = prop.split('.'); + let val = row; + props.forEach((p) => { + if (typeof val == 'object') { + val = val[p]; + } + }); + return val; } } } diff --git a/src/components/userlist.vue b/src/components/userlist.vue index 519fa5d..f2586a5 100644 --- a/src/components/userlist.vue +++ b/src/components/userlist.vue @@ -26,10 +26,14 @@ export default { prop: 'Username', orderBy: 'username' }, + { + heading: 'Reseller', + prop: 'Reseller.Username' + }, { heading: 'Render', render(row) { - return row.ID; + return 'ID:' + row.ID; } } ],