column filters in responsive table are now saved to session storage
This commit is contained in:
parent
6360cba756
commit
311acc4761
2 changed files with 12 additions and 5 deletions
|
|
@ -121,7 +121,18 @@ export default function ResponsiveTable<T extends Object>(props: Props<T>) {
|
||||||
const [openGutters, setOpenGutters] = useState<number[]>([])
|
const [openGutters, setOpenGutters] = useState<number[]>([])
|
||||||
const [handler, setHandler] = useState<NodeJS.Timeout | undefined>(undefined);
|
const [handler, setHandler] = useState<NodeJS.Timeout | undefined>(undefined);
|
||||||
const [columnAnchor, setColumnAnchor] = useState<any>(null)
|
const [columnAnchor, setColumnAnchor] = useState<any>(null)
|
||||||
const [filterList, setFilterList] = useState<string[]>([])
|
|
||||||
|
const filterKey = window.location.pathname.split('/').pop() + "-table-filter-list";
|
||||||
|
|
||||||
|
const [filterList, setFilterList] = useState<string[]>(() => {
|
||||||
|
const saved = localStorage.getItem(filterKey);
|
||||||
|
return saved ? JSON.parse(saved) : [];
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
console.log(filterList)
|
||||||
|
localStorage.setItem(filterKey, JSON.stringify(filterList));
|
||||||
|
}, [filterList])
|
||||||
|
|
||||||
const openColumnMenu = (event: any) => {
|
const openColumnMenu = (event: any) => {
|
||||||
setColumnAnchor(event.currentTarget);
|
setColumnAnchor(event.currentTarget);
|
||||||
|
|
|
||||||
|
|
@ -232,10 +232,6 @@ export default function Devices() {
|
||||||
loadGroups()
|
loadGroups()
|
||||||
}, [groupLimit, groupPage, orderGroup, orderGroupBy, searchGroup])
|
}, [groupLimit, groupPage, orderGroup, orderGroupBy, searchGroup])
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
console.log(search)
|
|
||||||
}, [search])
|
|
||||||
|
|
||||||
const handleChange = (event: any) => {
|
const handleChange = (event: any) => {
|
||||||
setLimit(event.target.value);
|
setLimit(event.target.value);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue