diff --git a/src/table/__tests__/base.test.jsx b/src/table/__tests__/base.test.jsx
index e0db637ab..21505e096 100644
--- a/src/table/__tests__/base.test.jsx
+++ b/src/table/__tests__/base.test.jsx
@@ -563,5 +563,55 @@ TABLES.forEach((TTable) => {
expect(wrapper.find('.t-table__top-content').text()).toBe(topContentText);
});
});
+ describe(':props.filterIcon', () => {
+ it('props.filterIcon could be function', async () => {
+ const filterIconText = () => '筛';
+ const filterColumns = SIMPLE_COLUMNS.map((item) => ({
+ ...item,
+ filter: { type: 'single', list: [{ label: 1, value: 2 }] },
+ }));
+
+ const wrapper = mount({
+ render() {
+ return ;
+ },
+ });
+
+ if (TTable.name === 'TBaseTable') {
+ expect(wrapper.find('.t-table__filter-icon').exists()).toBeFalsy();
+ } else {
+ expect(wrapper.find('.t-table__filter-icon').exists()).toBeTruthy();
+ expect(wrapper.find('.t-table__filter-icon').text()).toBe(filterIconText());
+ }
+ });
+
+ it('slots.filter-icon works fine', () => {
+ const filterIconText = (rowKey) => `筛${rowKey}`;
+ const filterColumns = SIMPLE_COLUMNS.map((item) => ({
+ ...item,
+ filter: { type: 'single', list: [{ label: 1, value: 2 }] },
+ }));
+ const wrapper = mount({
+ render() {
+ return (
+ filterIconText(col.col.colKey) }}
+ rowKey="index"
+ data={data}
+ columns={filterColumns}
+ >
+ );
+ },
+ });
+ if (TTable.name === 'TBaseTable') {
+ expect(wrapper.find('.t-table__filter-icon').exists()).toBeFalsy();
+ } else {
+ expect(wrapper.find('.t-table__filter-icon').exists()).toBeTruthy();
+ SIMPLE_COLUMNS.forEach((item, index) => {
+ expect(wrapper.findAll('.t-table__filter-icon').at(index).text()).toBe(filterIconText(item.colKey));
+ });
+ }
+ });
+ });
});
});
diff --git a/src/table/filter-controller.tsx b/src/table/filter-controller.tsx
index 2c1a487cb..f1b058cc3 100644
--- a/src/table/filter-controller.tsx
+++ b/src/table/filter-controller.tsx
@@ -13,7 +13,7 @@ import Input from '../input';
import TButton from '../button';
import { useTNodeDefault } from '../hooks/tnode';
import { useGlobalIcon } from '../hooks/useGlobalIcon';
-import { PrimaryTableCol, FilterValue } from './type';
+import { PrimaryTableCol, FilterValue, TdPrimaryTableProps } from './type';
import { useConfig } from '../config-provider/useConfig';
import log from '../_common/js/log';
import { AttachNode } from '../common';
@@ -45,6 +45,7 @@ export interface TableFilterControllerProps {
primaryTableElement: HTMLDivElement;
popupProps: PopupProps;
attach?: AttachNode;
+ filterIcon?: TdPrimaryTableProps['filterIcon'];
}
export default defineComponent({
@@ -60,6 +61,7 @@ export default defineComponent({
primaryTableElement: {},
popupProps: Object as PropType,
attach: [String, Function] as PropType,
+ filterIcon: [Function] as PropType,
},
// eslint-disable-next-line