Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

过滤案例有问题 FilterInput #34

Open
imp-oh opened this issue May 8, 2024 · 0 comments
Open

过滤案例有问题 FilterInput #34

imp-oh opened this issue May 8, 2024 · 0 comments

Comments

@imp-oh
Copy link

imp-oh commented May 8, 2024

错误示例地址 https://github.com/x-extends/vxe-table-docs/blob/main/v3/src/plugins/table/renderer/filter.tsx

// 创建一个简单的输入框筛选
VXETable.renderer.add('FilterInput', {
// 筛选模板
renderFilter (h, renderOpts, params) {
return
},
// 重置数据方法
filterResetMethod ({ options }) {
options.forEach(option => {
option.data = ''
})
},
// 重置筛选复原方法(当未点击确认时,该选项将被恢复为默认值)
filterRecoverMethod ({ option }) {
option.data = ''
},
// 筛选方法
filterMethod ({ option, row, column }) {
const { data } = option
// 这里如果是 number 类型匹配错误,示例可以更正一下
const cellValue = (typeof row[column.field]) === 'number' ? ${row[column.field]} : row[column.field]
if (cellValue) {
return cellValue.indexOf(data) > -1
}
return false
}
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant