@@ -20,13 +20,12 @@ const ReactDataTable = <TData,>(props: ReactDataTableProps<TData>) => {
2020 rowStyle,
2121 pageSizes,
2222 showPaging,
23+ onEnter,
2324 totalRecords = table . getCoreRowModel ( ) . rows . length ,
2425 } = props ;
2526
2627 const { pagination } = table . getState ( ) ;
2728
28- console . log ( table . getFooterGroups ( ) ) ;
29-
3029 return (
3130 < >
3231 { ! isLoading && isFetching && (
@@ -66,58 +65,72 @@ const ReactDataTable = <TData,>(props: ReactDataTableProps<TData>) => {
6665 } = header ;
6766
6867 return (
69- < >
70- < th >
71- { header . index === 0 && (
72- < >
68+ < th key = { header . id } >
69+ { header . index === 0 && (
70+ < >
71+ { onEnter && (
7372 < FontAwesomeIcon
7473 style = { { cursor : "pointer" , marginBottom : "4px" , marginRight : "5px" } }
7574 icon = { faSearch }
76- onClick = { ( ) => {
77- // onSearch();
78- } }
75+ onClick = { ( ) => onEnter ( table . getState ( ) . columnFilters ) }
7976 />
77+ ) }
8078
81- < FontAwesomeIcon
82- style = { { cursor : "pointer" , marginBottom : "4px" , marginRight : "5px" } }
83- icon = { faTimes }
84- onClick = { ( ) => {
85- table . resetColumnFilters ( ) ;
86- } }
87- />
88- </ >
89- ) }
79+ < FontAwesomeIcon
80+ style = { { cursor : "pointer" , marginBottom : "4px" , marginRight : "5px" } }
81+ icon = { faTimes }
82+ onClick = { ( ) => {
83+ if ( onEnter ) {
84+ onEnter ( [ ] ) ;
85+ }
9086
91- { header . column . getCanFilter ( ) && (
92- < >
93- { meta ?. dropdownFilter ? (
94- < Input
95- type = "select"
96- onChange = { ( e ) => {
97- header . column . setFilterValue ( e . target . value ) ;
98- } }
99- bsSize = "sm"
100- >
101- { meta . dropdownFilter . options . map ( ( { label, value } , i ) => (
102- < option key = { i } value = { value } >
103- { label }
104- </ option >
105- ) ) }
106- </ Input >
107- ) : (
108- < Input
109- type = "text"
110- value = { ( header . column . getFilterValue ( ) as string ) ?? "" }
111- onChange = { ( e ) => {
112- header . column . setFilterValue ( e . target . value ) ;
113- } }
114- bsSize = "sm"
115- > </ Input >
116- ) }
117- </ >
118- ) }
119- </ th >
120- </ >
87+ table . resetColumnFilters ( true ) ;
88+ } }
89+ />
90+ </ >
91+ ) }
92+
93+ { header . column . getCanFilter ( ) && (
94+ < >
95+ { meta ?. customFilter ? (
96+ meta ?. customFilter ( header . column . getFilterValue ( ) , header . column . setFilterValue )
97+ ) : meta ?. dropdownFilter ? (
98+ < Input
99+ type = "select"
100+ onChange = { ( e ) => {
101+ header . column . setFilterValue ( e . target . value ) ;
102+ } }
103+ onKeyUp = { ( { key } ) => {
104+ if ( key === "Enter" && onEnter ) {
105+ onEnter ( table . getState ( ) . columnFilters ) ;
106+ }
107+ } }
108+ bsSize = "sm"
109+ >
110+ { meta . dropdownFilter . options . map ( ( { label, value } , i ) => (
111+ < option key = { i } value = { value } >
112+ { label }
113+ </ option >
114+ ) ) }
115+ </ Input >
116+ ) : (
117+ < Input
118+ type = "text"
119+ value = { ( header . column . getFilterValue ( ) as string ) ?? "" }
120+ onChange = { ( e ) => {
121+ header . column . setFilterValue ( e . target . value ) ;
122+ } }
123+ onKeyUp = { ( { key } ) => {
124+ if ( key === "Enter" && onEnter ) {
125+ onEnter ( table . getState ( ) . columnFilters ) ;
126+ }
127+ } }
128+ bsSize = "sm"
129+ > </ Input >
130+ ) }
131+ </ >
132+ ) }
133+ </ th >
121134 ) ;
122135 } ) }
123136 </ tr >
0 commit comments