Manipulate PBA data to show multiple results of PBAs as separate entries in the report

This commit is contained in:
Shreya 2020-07-20 10:15:28 +05:30
parent 5fc6b6eb40
commit 1182a3ad03
1 changed files with 11 additions and 0 deletions

View File

@ -23,6 +23,17 @@ const subColumns = [
];
let renderDetails = function (data) {
data.forEach(pba => {
if (typeof pba['result'][0] === "object") { // if `result` has more than one entry
let results = pba['result'];
let details = data.splice(data.indexOf(pba), 1); // remove that pba from `data`
results.forEach(result => { // add back those results to `data` as individual pba entries
let tempDetails = JSON.parse(JSON.stringify(details));
tempDetails[0]['result'] = result;
data.push(tempDetails[0]);
});
}
});
let defaultPageSize = data.length > pageSize ? pageSize : data.length;
let showPagination = data.length > pageSize;
return <ReactTable