最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Antd: How to change tooltip label on table sorter - Stack Overflow

programmeradmin1浏览0评论

I'm new using Antd, I've create a table with sort functionalities, but I need to change the text on the tooltip of the sorter.

Sorter tooltip:-

Thanks in advance, if you need any extra code snippet just please let me know.

I'm new using Antd, I've create a table with sort functionalities, but I need to change the text on the tooltip of the sorter.

Sorter tooltip:-

Thanks in advance, if you need any extra code snippet just please let me know.

Share edited Mar 19, 2021 at 12:56 Anurag Dabas 24.3k9 gold badges24 silver badges41 bronze badges asked Mar 18, 2021 at 20:43 StepStep 1494 silver badges17 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 5

Based on this issue in github you can set locale property of Table to what you want

<Table 
      locale={{ 
          triggerDesc: 'descend sort text',
          triggerAsc: 'ascend sort text', 
          cancelSort: 'cancel sort text'
      }}
   />

Per the documentation, tables use the Sorter object, which implements a Tooltip.

You can find more information on the Table API here: https://ant.design/ponents/table/

And more on the Tooltip API here: https://ant.design/ponents/tooltip/#API

Essentially you'll want to set the yourTable.showSorterTooltip property to an object which contains the properties you want. It looks like the specific property you're looking for is just "title" but you can see the full list of properties in the Tooltip API

I was able to solve it this way:

<Table showSorterTooltip={{ title: 'Clic para ordenar' }}
       columns={tableColumn}
       dataSource={item}
       rowClassName='ps-pointer'
       rowKey={record => record.codigo_pedido_pra}
       style={{ cursor: 'pointer' }}
  />

The trick is to use the showSorterTooltip property.

If you want the same sorter message everywhere then you can just do:

<Table showSorterTooltip={true} />

or

<Table showSorterTooltip={{title: 'Sorter Title'}} />

but if you want to have different sorter message for different sort state in individual column ( when sort type is multiple ) then what you can do is:

  • maintain the sort state for the columns
  • Update the sort title as per the sort state in the column (ColumnType also has showSorterTooltip):
  • showSorterTooltip: {{title: 'Individual title'}}
发布评论

评论列表(0)

  1. 暂无评论