gregnb / mui-datatables

Datatables for React using Material-UI
MIT License
2.71k stars 934 forks source link

searching value in a Column not working when its searchable is set true and display set false #522

Open sanjanaHE opened 5 years ago

sanjanaHE commented 5 years ago

searching value in a Column not working when its searchable is set true and display set false

i have 10 columns with its options, i want to display only 5 columns is my view so other columns i have set display:"false", but for all columns searchable is set "true",

Expected Behavior

I need the search to work even the column display is false.

Current Behavior

turns out even though searchable is set true if display is false ,search wont work

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Your Environment

Tech Version
Material-UI
MUI-datatables
React
browser
etc
leducsang97 commented 5 years ago

same problem

sanjanaHE commented 5 years ago

hi, this is a serious issue ,please help

gregnb commented 5 years ago

Please post a reproducible example. In order to try to tackle these bugs there isn't enough time to recreate so I will need your help in posting a codesandbox. That will allow make it easier for others to look at the issue and potentially submit a fix. Thank you for understanding.

gabrielliwerant commented 5 years ago

This sounds like intentional functionality to me. When the column is not visible, I would not expect the user to receive results from it. Otherwise, how can they tell where those results came from? It's surprising UX behavior, and should not be default in my opinion.

However, you have the ability to customize search however you wish via the customSearch function. See the customize-search example for a demo use.

jarrisonfor commented 4 years ago

@sanjanaHE @leducsang97 I leave here how I did it, then it would be improvising depending on how you show the columns, such as if you have more columns than data

sorry for my english

            customSearch: (searchQuery, currentRow, columns) => {
                let isFound = false;
                columns.forEach((col, i) => {
                    if (col.searchable) {
                        if (currentRow[i].toString().indexOf(searchQuery) >= 0) {
                            isFound = true;
                        }
                    }
                });
                return isFound;
            },

edit: by default, all columns has searchable = true, you need change all columns to searchable: false and let in true the columns that you need to search

DemetriouJohn commented 4 years ago

edit: by default, all columns has searchable = true, you need change all columns to searchable: false and let in true the columns that you need to search

are we sure searchable: false works?