|
3 | 3 | * See the LICENSE file in the repository root folder for details. |
4 | 4 | */ |
5 | 5 |
|
6 | | -import { DataGrid, GridColDef, GridRow, GridRowProps, GridToolbar } from '@mui/x-data-grid'; |
| 6 | +import { DataGrid, GridColDef, GridFilterModel, GridRow, GridRowProps, GridToolbar } from '@mui/x-data-grid'; |
7 | 7 | import { routes } from '../../utils/routes'; |
8 | 8 | import { datePipe, fullNamePipe, wbsPipe } from '../../utils/pipes'; |
9 | 9 | import { useAllChangeRequests } from '../../hooks/change-requests.hooks'; |
@@ -135,6 +135,11 @@ const ChangeRequestsTable: React.FC = () => { |
135 | 135 | } |
136 | 136 | ]; |
137 | 137 |
|
| 138 | + const filterValues = JSON.parse( |
| 139 | + // sets filter to a default value if no filter is stored in local storage |
| 140 | + localStorage.getItem('changeRequestsTableFilter') ?? '{"columnField": "crId", "operatorValue": "=", "value": ""}' |
| 141 | + ); |
| 142 | + |
138 | 143 | return ( |
139 | 144 | <div> |
140 | 145 | <DataGrid |
@@ -182,7 +187,21 @@ const ChangeRequestsTable: React.FC = () => { |
182 | 187 | quickFilterProps: { debounceMs: 500 } |
183 | 188 | } |
184 | 189 | }} |
| 190 | + onFilterModelChange={(filterModel: GridFilterModel) => { |
| 191 | + localStorage.setItem('changeRequestsTableFilter', JSON.stringify(filterModel.items[0])); |
| 192 | + }} |
185 | 193 | initialState={{ |
| 194 | + filter: { |
| 195 | + filterModel: { |
| 196 | + items: [ |
| 197 | + { |
| 198 | + columnField: filterValues.columnField, |
| 199 | + operatorValue: filterValues.operatorValue, |
| 200 | + value: filterValues.value |
| 201 | + } |
| 202 | + ] |
| 203 | + } |
| 204 | + }, |
186 | 205 | sorting: { |
187 | 206 | sortModel: [{ field: 'crId', sort: 'desc' }] |
188 | 207 | }, |
|
0 commit comments