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

strict filtering for lists #1018

Open
aakashpolra opened this issue May 29, 2019 · 2 comments
Open

strict filtering for lists #1018

aakashpolra opened this issue May 29, 2019 · 2 comments

Comments

@aakashpolra
Copy link

aakashpolra commented May 29, 2019

There seems to be a filtering issue when the column filter type is set to 'list' and no custom filters are used, it does not filter "strictly".

For example, if the filter items in the list contain: "Car" and "Cardboard", selecting Car would also display Cardboard items.

The workaround here, of course, is to use a custom filter but I believe it makes sense to have the default behaviour to perform strict matches when using 'list' filter type. Alternatively, there could be an option to enable strict filtering.

@OwenLin-lwc
Copy link

OwenLin-lwc commented Aug 4, 2019

I use filterFunction to solve this problem.

export const TableConfig = {
columns: {
Item: {
filter: {
type: 'list'
config: {
selectText: 'All',
list: ['Car', 'Cardboard'],
}
},
filterFunction(cell?: string, search?:string): boolean {
return cell === search;
}
}
}
}

@renanaribeiro
Copy link

renanaribeiro commented Aug 26, 2019

I use filterFunction to solve this problem.

export const TableConfig = {
columns: {
Item: {
filter: {
type: 'list'
config: {
selectText: 'All',
list: ['Car', 'Cardboard'],
}
},
filterFunction(cell?: string, search?:string): boolean {
return cell === search;
}
}
}
}

This worked for me, thanks. Use the following as example:

columnName: {
title: 'Type',
type: 'list',
valuePrepareFunction: (type) => type.name, (if retrieved from nested json)
filterFunction(cell?: any, search?: any): boolean {
return cell.id === Number(search);
},
filter: {
type: 'list',
config: {
selectText: 'Select a type...',
list: [
{ value: 1, title: 'Type 1'},
{ value: 2, title: 'Number 2'},
{ value: 3, title: 'Others'},
],
},
},

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

3 participants