pro-components icon indicating copy to clipboard operation
pro-components copied to clipboard

antd-ProTable 查询表单Input.TextArea框输入值后按下回车会自动触发查询,这种情况,如果不希望回车触发查询,怎么做呢

Open Yellow-cxq opened this issue 3 years ago • 2 comments

Yellow-cxq avatar Mar 27 '23 07:03 Yellow-cxq

Protable的属性

form={{
        isKeyPressSubmit: false
      }}

cheneyg916 avatar Mar 29 '23 10:03 cheneyg916

TAutomatically replying with ChatGPT can be attempted, but it cannot be guaranteed to be completely accurate and may not fully address all issues. Please feel free to reply if you have any further questions or concerns. 此回复基于 ChatGPT 自动生成,可以尝试下方案,官方人员会在一定时间后继续继续处理。

您好,可以在 ProTable 组件中传递 form 属性,通过设置 isKeyPressSubmit 的值为 false,即可禁止按下回车触发查询事件。具体代码如下:

<ProTable
  form={{
    isKeyPressSubmit: false,
  }}
  ...
/>

另外,您也可以通过监听搜索表单的 onKeyDown 事件,并阻止默认行为来实现禁止按下回车触发查询,代码如下:

<ProTable
  onFormKeyDown={(event) => {
    if (event.keyCode === 13) {
      event.preventDefault();
    }
  }}
  ...
/>

上述两种方式都可以达到您不希望回车触发查询的要求。同时,您也可以查看 Antd ProTable 的官方文档,详细了解 ProTable 的属性和事件使用方法,以便更好地使用该组件。

chenshuai2144 avatar Apr 01 '23 08:04 chenshuai2144