diff --git a/src/components/DataTable/DataTable.spec.tsx b/src/components/DataTable/DataTable.spec.tsx
index 9f6981d73..2a38cd682 100644
--- a/src/components/DataTable/DataTable.spec.tsx
+++ b/src/components/DataTable/DataTable.spec.tsx
@@ -1045,5 +1045,35 @@ describe('DataTable', () => {
);
});
});
+
+ describe('cellValue is a function', () => {
+ it('should pass column width as a prop to cellValue', () => {
+ const testDataWithFunctionInCellValue: any = [
+ {
+ id: 1,
+ first_name: 'Isaac',
+ email: 'inewton@example.com',
+ occupation: 'Physicist',
+ isDisabled: true,
+ isSelected: true,
+ isActive: true,
+ status: (width) => ,
+ },
+ ];
+
+ const wrapper = mount(
+
+
+
+
+
+
+
+
+ );
+
+ expect(wrapper.find(Checkbox).props()).toHaveProperty('width');
+ });
+ });
});
});
diff --git a/src/components/DataTable/DataTable.tsx b/src/components/DataTable/DataTable.tsx
index 8ba893747..2266b7de0 100644
--- a/src/components/DataTable/DataTable.tsx
+++ b/src/components/DataTable/DataTable.tsx
@@ -456,7 +456,11 @@ export const DataTable = (props: IDataTableProps) => {
}
truncateContent={truncateContent}
>
- {isEmpty ? emptyCellText : cellValue}
+ {isEmpty
+ ? emptyCellText
+ : _.isFunction(cellValue)
+ ? cellValue(columnProps.width)
+ : cellValue}
);
}