table column with subobjects

This commit is contained in:
Sebastian Frank 2017-08-25 13:28:57 +02:00
parent 038582b454
commit 5b250b02fe
No known key found for this signature in database
GPG Key ID: DC2BC5C506EBF6F3
2 changed files with 16 additions and 2 deletions

View File

@ -13,7 +13,7 @@
<tbody is="transition-group" name="list">
<tr v-for="(r, ri) in rows" :key="ri">
<td v-for="(c, ci) in columns" :key="ci + 'c'">
<span v-if="c.prop">{{ r[c.prop] }}</span>
<span v-if="c.prop">{{ getProp(r, c.prop) }}</span>
<span v-else-if="c.render">{{ c.render(r) }}</span>
</td>
</tr>
@ -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;
}
}
}

View File

@ -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;
}
}
],