Skip to content

Commit 4055a23

Browse files
committed
docs: update demo
1 parent fc206c7 commit 4055a23

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

components/table/demo/custom-filter-panel.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Implement a customized column search example via `filterDropdown`.
1313
<a-table :dataSource="data" :columns="columns">
1414
<div slot="filterDropdown" slot-scope="{ setSelectedKeys, selectedKeys, confirm, clearFilters, column }" class='custom-filter-dropdown'>
1515
<a-input
16-
ref="searchInput"
16+
v-ant-ref="c => searchInput = c"
1717
:placeholder="`Search ${column.dataIndex}`"
1818
:value="selectedKeys[0]"
1919
@change="e => setSelectedKeys(e.target.value ? [e.target.value] : [])"
@@ -74,6 +74,7 @@ export default {
7474
return {
7575
data,
7676
searchText: '',
77+
searchInput: null,
7778
columns: [{
7879
title: 'Name',
7980
dataIndex: 'name',
@@ -87,8 +88,8 @@ export default {
8788
onFilterDropdownVisibleChange: (visible) => {
8889
if (visible) {
8990
setTimeout(() => {
90-
this.$refs.searchInput.focus()
91-
})
91+
this.searchInput.focus()
92+
},0)
9293
}
9394
},
9495
}, {
@@ -101,6 +102,13 @@ export default {
101102
customRender: 'customRender',
102103
},
103104
onFilter: (value, record) => record.age.toLowerCase().includes(value.toLowerCase()),
105+
onFilterDropdownVisibleChange: (visible) => {
106+
if (visible) {
107+
setTimeout(() => {
108+
this.searchInput.focus()
109+
})
110+
}
111+
},
104112
}, {
105113
title: 'Address',
106114
dataIndex: 'address',
@@ -111,6 +119,13 @@ export default {
111119
customRender: 'customRender',
112120
},
113121
onFilter: (value, record) => record.address.toLowerCase().includes(value.toLowerCase()),
122+
onFilterDropdownVisibleChange: (visible) => {
123+
if (visible) {
124+
setTimeout(() => {
125+
this.searchInput.focus()
126+
})
127+
}
128+
},
114129
}],
115130
}
116131
},

0 commit comments

Comments
 (0)