More input on search

More input on search

massive70massive70 Posts: 2Questions: 1Answers: 0
edited February 2021 in Free community support

Hi,
i need to add another search input. I have something like that:

The goal is: "Input Search 1" search only on columns A, B and C, instead "Input Search 2" search only on column D with these conditions:

1) If Seach1 == "" AND Search2 == "", return all rows;
2) If Seach1 != "" AND Search2 == "", return rows with search only on columns A,B,C
3) If Seach1 == "" AND Search2 != "", return rows with search only on search only on D
4) If Seach1 != "" AND Search2 != "", return rows with search on columns A,B,C AND column D

I provide a test case:
http://live.datatables.net/zimamiwe/4/edit

When the page is reloaded or a column is sorted, the search is reset. How i can save and preserve the state (search, sorting, etc..) like a default search?

Unfortunately, I can't use a multiple individual column searches or SearchsPanes.

thanks

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,250Questions: 26Answers: 4,761
    Answer ✓

    When the page is reloaded or a column is sorted, the search is reset. How i can save and preserve the state (search, sorting, etc..) like a default search?

    Don't pop the search plugin. If you pop it then it won't be active for the next draw like sorting, etc. Push it once so it runs for each table draw. Your updated example:
    http://live.datatables.net/zimamiwe/5/edit

    Kevin

  • massive70massive70 Posts: 2Questions: 1Answers: 0

    Thank you for reply.

    I have solved also the problem with page reload adding extra custom parameters with stateSaveParams and stateLoadParams:

    http://live.datatables.net/zimamiwe/10/edit

  • kthorngrenkthorngren Posts: 20,250Questions: 26Answers: 4,761

    Sorry, I missed that part :smile: Glad you got it all working.

    Kevin

This discussion has been closed.