javascript - 如何添加切换按钮等操作来更改列表视图中某些字段的值?
问题描述
我想在 ListView 中添加可编辑字段,例如<BooleanInput />
更改列表视图中某些字段的值。但是在阅读完文档后,我找不到任何想法。因为现在我对列表视图唯一能做的就是不可编辑的字段,例如<BooleanField />, <TextField />
,...请提供一些建议或想法。太感谢了。
解决方案
如果您想在列表中编辑这些条目,以下文章显示了如何将编辑放入列表中:https ://marmelab.com/blog/2019/01/09/react-admin-2-6.html#datagrid -扩展面板
const UserEdit = props => (
<Edit
{...props}
/* disable the app title change when shown */
title=" "
>
<SimpleForm
/* The form must have a name dependent on the record, because by default all
forms have the same name */
form={`post_edit_${props.id}`}
>
<TextInput source="name" />
</SimpleForm>
</Edit>
);
const UserList = props => (
<List {...props}>
<Datagrid expand={<UserEdit />}>
<TextField source="id" />
<TextField source="name" />
<TextField source="role" />
</Datagrid>
</List>
);
推荐阅读
- computer-vision - RetinaNet 中的焦点损失
- mongodb - 如何在 MongoDB 中将集合导出到 TSV
- axis2 - 无法使用 jibx 解析解组 xsi:nil=true
- github - 如何使用 ssh_rsa 密钥对创建从 jupyter notebook 到 github 的永久登录
- mysql - 按两个表分组,然后附加结果并删除重复项
- ruby - Ruby `uniq` 方法用于相等性检查是什么?
- javascript - 如何使用从 Redux 返回的嵌套数据结构而不会遇到诸如“无法访问未定义的属性 x”之类的错误?
- sql-server-2012 - 无法在具有子查询的带有 SCHEMABINDING 的视图上创建 UNIQUE CLUSTERED INDEX
- c# - 如何使用 RESTSharp 获取响应标头?
- c# - 使用 ASP.NET 的 JSON 输出不正确