From 0c93bd352723dfe648d96b8a99b5d562e0cd8c8b Mon Sep 17 00:00:00 2001 From: Akshay Anand Date: Tue, 5 Sep 2017 22:02:34 -0400 Subject: [PATCH] Formatted Row for dynamic table --- README.md | 8 ++++++-- src/components/Table.vue | 11 ++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6b62bee2..f193f34e 100644 --- a/README.md +++ b/README.md @@ -116,12 +116,16 @@ This should result in the screenshot seen above ``` -In addition to `prop.row` that contains the row object, `prop.index` contains the index for the table display row. And `prop.row.originalIndex` contains the original row index. You can access the original row object by using `row[prop.row.originalIndex]`. +**Note:** +* The original row object can be accessed via `prop.row` +* The currently displayed table row index can be accessed via `prop.index` . +* The original row index can be accessed via `prop.row.originalIndex`. You can access the original row object by using `row[prop.row.originalIndex]`. +* You can access the formatted row data (for example - formatted date) via `prop.formattedRow` ### Component Options diff --git a/src/components/Table.vue b/src/components/Table.vue index ee2390bf..00acb931 100644 --- a/src/components/Table.vue +++ b/src/components/Table.vue @@ -52,7 +52,7 @@ {{ getCurrentIndex(index) }} - + {{ collectFormatted(row, column) }} @@ -237,6 +237,15 @@ import compareAsc from 'date-fns/compare_asc'; } }, + formattedRow(row) { + var formattedRow = {}; + for(const col of this.columns) { + for(const key in row) { + formattedRow[key] = this.collectFormatted(row, col); + } + } + return formattedRow; + }, // Get the necessary style-classes for the given column //--------------------------------------------------------