From 622519cb4d9cb0ec42b6bb37e82bdfc71511a7e3 Mon Sep 17 00:00:00 2001 From: RajaSekhar K Date: Thu, 10 Oct 2019 18:37:23 +0530 Subject: [PATCH] Split the table row if the json field value is of type array --- src/js/json.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/js/json.js b/src/js/json.js index d02b3db..c1966fa 100644 --- a/src/js/json.js +++ b/src/js/json.js @@ -95,7 +95,13 @@ function jsonToHTML (params) { } // Add the row contents and styles - htmlData += '' + stringData + '' + // if the data is of type array, splitting the cell to multiple rows + if (typeof stringData === 'object' && stringData.length && stringData.length > 0) { + const subTableHtmlData = stringData.reduce((acc, eachRowData) => (acc + '' + eachRowData + ''), '') + htmlData += '' + subTableHtmlData + '
' + } else { + htmlData += '' + stringData + '' + } } // Add the row closing tag