M
M
Mesuti2020-04-23 16:08:49
JavaScript
Mesuti, 2020-04-23 16:08:49

How to do a search on each column?

Hey!
There is a table with a search for each column and a general search.

Why is the search script not working?
It seems that everything is logically designed

. Each input is stored in the state so that the next input is searched for by previous results.
For some reason this script is not working.

dataHave.map(item => { // перебор массива объектов, где ищем слова
      for (let key in searchHave) {  // перебор каждого input для поиска
        JSON.stringify(item) // объект из массива для поиска превращаем в строку
          .toUpperCase()
          .indexOf(searchHave[key].toUpperCase()) > -1 // поиск каждого input
          ? filteredData.push(item) // если вхождения найдены - сохраняем элемент в новый массив 
          : false;
      }
    });


Sandbox
state.data - an array for output to the page
state.json - an array received from the server
state.search - an object with an input for searching
codesandbox

I feel very confused, I will be grateful for any answer, at least the direction where to move.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-04-23
@Mesuti

https://codesandbox.io/s/for-httpsqnahabrcomq75703...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question