バージョン: Next
(react-admin)
リソースClasses
とStudents
.
「Students」には「Classes」への外部キーがあります: class_id
。
そのため、各行 (クラス) には、[クラスの生徒を表示/編集] ボタンがありますList
。Classes
このボタンをクリックすると、次のコードが表示されます。
<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?