individual column searching example, saved input not visible

individual column searching example, saved input not visible

ooiooooioo Posts: 23Questions: 4Answers: 0

Hi,
using in my code the individual column searching example :
https://datatables.net/examples/api/multi_filter.html
if I go to another page and come back to this page, the search values are saved and effective, but they are not visible in the input fields.
How could I made them visible when coming back or avoid them to be saved ?

Thanks,
Pierre.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,344Questions: 26Answers: 4,776
    Answer ✓

    Sounds like you have stateSave enabled. You will need to repopulate the search inputs. See this thread for a solution.

    Kevin

  • ooiooooioo Posts: 23Questions: 4Answers: 0

    Thanks a lot Kevin it works fine !

    initComplete: function() {
        this.api()
            .columns()
            .every(function() {
                const column = this;
                const input = document.createElement('input');
                input.placeholder = column.footer().textContent;
                column.footer().replaceChildren(input);
                input.addEventListener('keyup', () => {
                    if (column.search() !== this.value) {
                        column.search(input.value).draw();
                    }
                });
                // Restore state saved values
                const state = column.state.loaded();
                if (state) {
                    const val = state.columns[column.index()];
                    input.value = val.search.search;
                }
            });
    }
    

    Pierre.

  • ooiooooioo Posts: 23Questions: 4Answers: 0

    I wonder too about this note in this example description :
    "Note that the index:visible option is used for the column selector to ensure that the column() method takes into account any hidden columns when selecting the column to act upon. "

    Where is this :visible selector ?

    Pierre.

  • kthorngrenkthorngren Posts: 20,344Questions: 26Answers: 4,776

    See the jQuery :visible selecotr. The column-selector docs have examples of using jQuery selectors in the column() API.

    Kevin

Sign In or Register to comment.