Skip to content

Commit

Permalink
Make ElementKey optional (#831)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
  • Loading branch information
dvaldivia committed Jun 23, 2021
1 parent 9f4d3f4 commit fa85ad9
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export interface ItemActions {

interface IColumns {
label: string;
elementKey: string;
elementKey?: string;
renderFunction?: (input: any) => any;
renderFullObject?: boolean;
globalClass?: any;
Expand Down Expand Up @@ -300,7 +300,7 @@ const subRenderFunction = (
) => {
const itemElement = isString(rowData)
? rowData
: get(rowData, column.elementKey, null); // If the element is just a string, we render it as it is
: get(rowData, column.elementKey!, null); // If the element is just a string, we render it as it is
const renderConst = column.renderFullObject ? rowData : itemElement;

const renderElement = column.renderFunction
Expand Down Expand Up @@ -328,7 +328,7 @@ const calculateColumnRest = (

if (columnsSelector) {
colsItems = columns.filter((column) =>
columnsShown.includes(column.elementKey)
columnsShown.includes(column.elementKey!)
);
}

Expand Down Expand Up @@ -373,7 +373,7 @@ const generateColumnsMap = (
columnsShown
);
return columns.map((column: IColumns, index: number) => {
if (columnsSelector && !columnsShown.includes(column.elementKey)) {
if (columnsSelector && !columnsShown.includes(column.elementKey!)) {
return null;
}

Expand All @@ -382,7 +382,7 @@ const generateColumnsMap = (
return (
<Column
key={`col-tb-${index.toString()}`}
dataKey={column.elementKey}
dataKey={column.elementKey!}
headerClassName={`titleHeader ${
column.headerTextAlign ? `text-${column.headerTextAlign}` : ""
}`}
Expand Down Expand Up @@ -576,9 +576,9 @@ const TableWrapper = ({
<CheckboxWrapper
key={`tableColumns-${column.label}`}
label={column.label}
checked={columnsShown.includes(column.elementKey)}
checked={columnsShown.includes(column.elementKey!)}
onChange={(e) => {
onColumnChange(column.elementKey, e.target.checked);
onColumnChange(column.elementKey!, e.target.checked);
}}
id={`chbox-${column.label}`}
name={`chbox-${column.label}`}
Expand Down

0 comments on commit fa85ad9

Please sign in to comment.