简体   繁体   English

Ant 设计表搜索和排序器定制

[英]Ant Design table search and sorter customization

Is there a simple fix to prevent the table from sorting when clicking into input on table header?单击表 header 上的输入时,是否有一个简单的修复程序可以防止表排序?

Code Sandbox 代码沙盒

I tried to add onclick handler to the input search field, but did not help.我试图将 onclick 处理程序添加到输入搜索字段,但没有帮助。

onClick={(e) => e.preventDefault()}

This happens because of events bubbling.发生这种情况是因为事件冒泡。 You can read about events propagation here https://javascript.info/bubbling-and-capturing .您可以在此处阅读有关事件传播的信息https://javascript.info/bubbling-and-capturing

In your case you should stopPropagation on input click event.在您的情况下,您应该在输入点击事件时stopPropagation

<Input
     ...
      onClick={(e) => {
        e.stopPropagation();
      }}
   ...
 />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM