【发布时间】:2022-08-20 02:35:54
【问题描述】:
我正在学习反应管理员,我有一个简单的页面,其中包含一些过滤器,如下所示:
import * as React from \"react\";
import { List, TextField, Datagrid, TextInput } from \'react-admin\';
import { PostPaginationm } from \"./MyPagination\";
const postFilters = [
<TextInput label=\'Field\' source=\"_Field-Name_matches\" alwayson alwaysOn />,
<TextInput label=\'Index\' source=\"_Index-Name\" alwaysOn />,
<TextInput label=\'File\' source=\"_File-Name\" alwaysOn />,
<TextInput label=\'Db\' source=\"_db-name\" alwaysOn />,
];
export const IndexFieldSchemaList = () => (
<List filters={postFilters} pagination={<PostPaginationm/>}>
<Datagrid>
<TextField source=\"id\" label=\"Id\"/>
<TextField source=\"_db-name\" label=\"Db\"/>
<TextField source=\"_File-Name\" label=\"File\"/>
<TextField source=\"_Index-Seq\" label=\"Seq\"/>
<TextField source=\"_Index-Name\" label=\"Index\"/>
<TextField source=\"_Field-Name\" label=\"Field\"/>
<TextField source=\"_Ascending\" label=\"Asc\"/>
<TextField source=\"_Abbreviate\" label=\"Abbr\"/>
</Datagrid>
</List>
);
当我填写其中一个过滤器时,我得到以下 GET 操作:
GET http://localhost:12537/React/web/table/indexfieldschema?filter={\"_File-Name\":\"extent\"}&range=[0,49]&sort=[\"id\",\"ASC\"]
以前我会得到这样的东西,其中将“q”字段添加到过滤器中:
GET http://localhost:12537/React/web/table/indexfieldschema?filter={\"q\": \"e\", \"_File-Name\":\"extent\"}&range=[0,49]&sort=[\"id\",\"ASC\"]
我已经对 API 进行了编码以使用“q”规范 - 没有它执行直接相等匹配,它不会按照我想要的方式过滤记录。
如何以我需要的方式将“q”字段添加到过滤器中?我注意到,当我最初编写此代码时,它添加了 \"q\" 字段,所以我不确定是什么改变来阻止这种行为。
事实证明,\'q\' 规范并没有像我想象的那样工作,也没有给我想要的功能,所以答案就是我如何得到我想要的。
标签: react-admin