Use nested params as table column values

This commit is contained in:
navaneeth 2021-04-08 13:19:38 +05:30
parent e355391a4e
commit 7a7325adf5

View file

@ -1,5 +1,5 @@
import React from 'react';
import { resolve } from '@/_helpers/utils';
import { resolve, findProp } from '@/_helpers/utils';
export const Table = function Table({ id, component, onComponentClick, currentState, onEvent }) {
@ -15,6 +15,10 @@ export const Table = function Table({ id, component, onComponentClick, currentSt
data = resolve(component.definition.properties.data.value, currentState, []);
console.log('resolved param', data);
}
function findColumnValue(row, name) {
return findProp(row, name);
}
// Quick fix, need to remove later
data = data ? data : [];
@ -40,7 +44,7 @@ export const Table = function Table({ id, component, onComponentClick, currentSt
{data.map((row =>
<tr onClick={(e) => { e.stopPropagation(); onEvent('onRowClicked', { component, row }); }}>
{columns.map((column) => <td>{row[column.name]}</td>)}
{columns.map((column) => <td>{findColumnValue(row, column.name)}</td>)}
{actions.value.length > 0 &&
<td>