Make ElementKey optional (#831)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
@@ -53,7 +53,7 @@ export interface ItemActions {
|
|||||||
|
|
||||||
interface IColumns {
|
interface IColumns {
|
||||||
label: string;
|
label: string;
|
||||||
elementKey: string;
|
elementKey?: string;
|
||||||
renderFunction?: (input: any) => any;
|
renderFunction?: (input: any) => any;
|
||||||
renderFullObject?: boolean;
|
renderFullObject?: boolean;
|
||||||
globalClass?: any;
|
globalClass?: any;
|
||||||
@@ -300,7 +300,7 @@ const subRenderFunction = (
|
|||||||
) => {
|
) => {
|
||||||
const itemElement = isString(rowData)
|
const itemElement = isString(rowData)
|
||||||
? 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 renderConst = column.renderFullObject ? rowData : itemElement;
|
||||||
|
|
||||||
const renderElement = column.renderFunction
|
const renderElement = column.renderFunction
|
||||||
@@ -328,7 +328,7 @@ const calculateColumnRest = (
|
|||||||
|
|
||||||
if (columnsSelector) {
|
if (columnsSelector) {
|
||||||
colsItems = columns.filter((column) =>
|
colsItems = columns.filter((column) =>
|
||||||
columnsShown.includes(column.elementKey)
|
columnsShown.includes(column.elementKey!)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,7 +373,7 @@ const generateColumnsMap = (
|
|||||||
columnsShown
|
columnsShown
|
||||||
);
|
);
|
||||||
return columns.map((column: IColumns, index: number) => {
|
return columns.map((column: IColumns, index: number) => {
|
||||||
if (columnsSelector && !columnsShown.includes(column.elementKey)) {
|
if (columnsSelector && !columnsShown.includes(column.elementKey!)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,7 +382,7 @@ const generateColumnsMap = (
|
|||||||
return (
|
return (
|
||||||
<Column
|
<Column
|
||||||
key={`col-tb-${index.toString()}`}
|
key={`col-tb-${index.toString()}`}
|
||||||
dataKey={column.elementKey}
|
dataKey={column.elementKey!}
|
||||||
headerClassName={`titleHeader ${
|
headerClassName={`titleHeader ${
|
||||||
column.headerTextAlign ? `text-${column.headerTextAlign}` : ""
|
column.headerTextAlign ? `text-${column.headerTextAlign}` : ""
|
||||||
}`}
|
}`}
|
||||||
@@ -576,9 +576,9 @@ const TableWrapper = ({
|
|||||||
<CheckboxWrapper
|
<CheckboxWrapper
|
||||||
key={`tableColumns-${column.label}`}
|
key={`tableColumns-${column.label}`}
|
||||||
label={column.label}
|
label={column.label}
|
||||||
checked={columnsShown.includes(column.elementKey)}
|
checked={columnsShown.includes(column.elementKey!)}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
onColumnChange(column.elementKey, e.target.checked);
|
onColumnChange(column.elementKey!, e.target.checked);
|
||||||
}}
|
}}
|
||||||
id={`chbox-${column.label}`}
|
id={`chbox-${column.label}`}
|
||||||
name={`chbox-${column.label}`}
|
name={`chbox-${column.label}`}
|
||||||
|
|||||||
Reference in New Issue
Block a user