Skip to content

Commit 4911951

Browse files
authored
Add flags for striped rows and clear search button in ReactDataTable (#79)
1 parent 7274275 commit 4911951

3 files changed

Lines changed: 35 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- added a flag `isStriped` to the `ReactDataTable` component to enable/disable striped rows
13+
- added a flag `showClearSearchButton` to the `ReactDataTable` component to show/hide the clear search button
14+
1015
## [5.10.0] - 2025-04-29
1116

1217
### Added

src/lib/ReactDataTable/ReactDataTable.tsx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ const ReactDataTable = <TData, TFilter extends FilterModel = Record<string, neve
4545
noEntriesMessage,
4646
onRowClick,
4747
enableRowClick,
48+
isStriped = true,
49+
showClearSearchButton = true,
4850
} = props;
4951

5052
const { pagination } = table.getState();
@@ -116,7 +118,7 @@ const ReactDataTable = <TData, TFilter extends FilterModel = Record<string, neve
116118
>
117119
<style>{loadingCss}</style>
118120
<ReactStrapTable
119-
striped
121+
striped={isStriped}
120122
hover
121123
size="sm"
122124
className={tableClassName}
@@ -196,20 +198,22 @@ const ReactDataTable = <TData, TFilter extends FilterModel = Record<string, neve
196198
/>
197199
)}
198200

199-
<FontAwesomeIcon
200-
style={{ cursor: "pointer", marginBottom: "4px", marginRight: "5px" }}
201-
icon={faTimes}
202-
onClick={() => {
203-
if (onEnter) {
204-
onEnter(getModelFromColumnFilter(table.initialState.columnFilters));
205-
}
201+
{showClearSearchButton && (
202+
<FontAwesomeIcon
203+
style={{ cursor: "pointer", marginBottom: "4px", marginRight: "5px" }}
204+
icon={faTimes}
205+
onClick={() => {
206+
if (onEnter) {
207+
onEnter(getModelFromColumnFilter(table.initialState.columnFilters));
208+
}
206209

207-
table.setColumnFilters(table.initialState.columnFilters);
208-
if (manualPagination) {
209-
resetPageIndex(true);
210-
}
211-
}}
212-
/>
210+
table.setColumnFilters(table.initialState.columnFilters);
211+
if (manualPagination) {
212+
resetPageIndex(true);
213+
}
214+
}}
215+
/>
216+
)}
213217
</>
214218
)}
215219
{header.column.getCanFilter() && (

src/lib/ReactDataTable/ReactDataTableProps.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,16 @@ export interface ReactDataTableProps<TData, TFilter extends FilterModel> {
101101
* to override the default message in case no entries is found
102102
*/
103103
noEntriesMessage?: string;
104+
105+
/**
106+
* boolean flag to indicate if the table should be striped
107+
* @default true
108+
*/
109+
isStriped?: boolean;
110+
111+
/**
112+
* boolean flag to indicate if the table should have hover effect
113+
* @default true
114+
*/
115+
showClearSearchButton?: boolean;
104116
}

0 commit comments

Comments
 (0)