批量操作执行后如何取消选择复选框? [英] How to unselect checkboxes after bulk action execution?
问题描述
在 List
模块上,我创建了一个批量操作按钮,通过调用自定义操作来生成PDF。
问题是< Datagrid>
动作一旦执行便未被取消。
On a List
module, I created a bulk action button to generate PDF by calling a custom action.
The problem is <Datagrid>
checkboxes are not unselected once the action is executed.
此处是我的自定义操作:
Here is my custom action:
export const print = (resource, ids, data) => ({
type: DOWNLOAD,
payload: {
id: ids.length === 1 ? ids[0] : ids,
data,
},
meta: {
resource: resource,
fetch: PRINT,
onFailure: {
notification: {
body: 'ra.notification.http_error',
level: 'warning',
},
},
},
});
这是我的按钮:
And here is my button:
class PrintBulkButton extends React.Component {
handleClick = () => {
const { basePath, options, print, resource, selectedIds } = this.props;
print(resource, selectedIds, options, basePath);
};
render() {
return (
<Button {...sanitizeRestProps(this.props)} onClick={this.handleClick}>
{this.props.icon}
</Button>
);
}
}
我正在使用react-admin 2.3.0,
I'm using react-admin 2.3.0, but it wasn't working with previous versions either.
我认为复选框未被取消,因为我调用的服务不会更新数据。
我说得对吗?
I think the checkboxes are not unchecked because the service I call doesn't update data. Am I right?
我是否必须致电其他服务或采取行动取消选中它们,或者我错过了什么?
Do I have to call another service or action to uncheck them, or am I missing something?
推荐答案
您可以添加此 onSuccess
副作用参数 unselectAll:true
,我们应该记录下来(请为此打开一个问题):
You can add this onSuccess
side effect parameter unselectAll: true
that we should document (please open an issue for it):
export const print = (resource, ids, data) => ({
type: DOWNLOAD,
payload: {
id: ids.length === 1 ? ids[0] : ids,
data,
},
meta: {
resource: resource,
fetch: PRINT,
onSuccess: {
unselectAll: true,
},
onFailure: {
notification: {
body: 'ra.notification.http_error',
level: 'warning',
},
},
},
});
这篇关于批量操作执行后如何取消选择复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!