Version: Next
(react-admin)
Resources Classes
and Students
.
"Students" has a foreign key to "Classes": class_id
.
So, in the List
of Classes
we have for each row (class) a button "View/Edit Students of Class".
When we click on this button, we have this code:
<Button
label={'View/Edit Students of Class'}
onClick={(e) => {
localStorage.setItem('classId', record.id);
history.push({
pathname: 'students',
search: stringify({
page: 1,
perPage: 25,
sort: 'createdOn',
order: 'DESC',
classId: record.id,
}),
})
}}
>
The idea is that we need somehow to get a 'classId' value in all CRUD operations of the 'Student', so that we filter by 'classId' in List and use this classId as a disabled field in CREATE.
I tried 2 ways: localStorage
or query params
as you can see in the code.
But these are not good, not working as expected (query params are lost when CREATE redirects, etc.)
Any ideas?