@@ -13,7 +13,7 @@ Implement a customized column search example via `filterDropdown`.
13
13
<a-table :dataSource =" data" :columns =" columns" >
14
14
<div slot =" filterDropdown" slot-scope =" { setSelectedKeys, selectedKeys, confirm, clearFilters, column }" class =' custom-filter-dropdown' >
15
15
<a-input
16
- ref =" searchInput"
16
+ v-ant- ref =" c => searchInput = c "
17
17
:placeholder =" `Search ${column.dataIndex}`"
18
18
:value =" selectedKeys[0]"
19
19
@change =" e => setSelectedKeys(e.target.value ? [e.target.value] : [])"
@@ -74,6 +74,7 @@ export default {
74
74
return {
75
75
data,
76
76
searchText: ' ' ,
77
+ searchInput: null ,
77
78
columns: [{
78
79
title: ' Name' ,
79
80
dataIndex: ' name' ,
@@ -87,8 +88,8 @@ export default {
87
88
onFilterDropdownVisibleChange : (visible ) => {
88
89
if (visible) {
89
90
setTimeout (() => {
90
- this .$refs . searchInput .focus ()
91
- })
91
+ this .searchInput .focus ()
92
+ }, 0 )
92
93
}
93
94
},
94
95
}, {
@@ -101,6 +102,13 @@ export default {
101
102
customRender: ' customRender' ,
102
103
},
103
104
onFilter : (value , record ) => record .age .toLowerCase ().includes (value .toLowerCase ()),
105
+ onFilterDropdownVisibleChange : (visible ) => {
106
+ if (visible) {
107
+ setTimeout (() => {
108
+ this .searchInput .focus ()
109
+ })
110
+ }
111
+ },
104
112
}, {
105
113
title: ' Address' ,
106
114
dataIndex: ' address' ,
@@ -111,6 +119,13 @@ export default {
111
119
customRender: ' customRender' ,
112
120
},
113
121
onFilter : (value , record ) => record .address .toLowerCase ().includes (value .toLowerCase ()),
122
+ onFilterDropdownVisibleChange : (visible ) => {
123
+ if (visible) {
124
+ setTimeout (() => {
125
+ this .searchInput .focus ()
126
+ })
127
+ }
128
+ },
114
129
}],
115
130
}
116
131
},
0 commit comments