using stateSave in conjunction with a pre-filter

using stateSave in conjunction with a pre-filter

crush123crush123 Posts: 417Questions: 126Answers: 18

my datatable has stateSave: true enabled.

i have set up a filter in a link from another page to easily identify a unique row in my table

"search": {"search": "<?php echo isset($_GET['filter'])?addslashes($_GET['filter']):'';?>"},

so that when my page is loaded, the datatable filter is pre-set

this works perfectly if stateSave is false, but not when it is true

is this expected behaviour ?

i think i can get around this with a bit of php by setting stateSave to true/false depending is there is a url parameter, but wondered if this was the best approach

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Yes this is expected behaviour - if you enable state saving then the last search value is restored :-).

    If you don't want to save the search value you could delete that parameter from the state saving object using the stateSaveCallback option.

    Allan

This discussion has been closed.