Deep Linking and stateSave

Deep Linking and stateSave

trongarttrongart Posts: 222Questions: 51Answers: 0

Using deep linking as described here with stateSave does not seem to work as stateSave saves the search filter value. I tried to apply the following, but this does not help as it simply empties the search filter:

"stateSaveParams": function (settings, data) {
data.search.search = "";
}

How can I prevent stateSave from even accessing the search filter so it can work with search.search?

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 21,334Questions: 26Answers: 4,951
    Answer ✓

    Instead of using data.search.search = "";, which will clear the search you might need to delete the search.search property. See if this works:

    delete data.search.search;
    

    Kevin

  • trongarttrongart Posts: 222Questions: 51Answers: 0

    That works! Thank you!!

  • trongarttrongart Posts: 222Questions: 51Answers: 0
    edited December 2021

    Is there also a way to prevent the searchBuilder conditions from being saved in stateSave? I tried the following under stateSaveParams, but this does not work:
    delete data.searchBuilder.getDetails();

  • kthorngrenkthorngren Posts: 21,334Questions: 26Answers: 4,951

    I'm not sure of what exactly to delete, without setting it up to look at, but you can find out by using console.log(data) in the option stateSaveParams function. You will see all the data being saved.

    Kevin

  • trongarttrongart Posts: 222Questions: 51Answers: 0
    edited December 2021

    Thank you! I can find both search and the searchBuilder under console.log(data), but adding console.log(data.searchBuilder); to stateSaveParams produces undefined. How could I empty all searchBuilder criteria so none are saved with stateSave?

  • kthorngrenkthorngren Posts: 21,334Questions: 26Answers: 4,951
    Answer ✓

    The SearchBuilder extension must add the searchBuilder property outside of stateSaveParams. So you won't have access to it there. Use stateLoadParams instead, like this:
    http://live.datatables.net/nipebate/1/edit

    Kevin

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    I would do the remove in the stateLoadParams, that's the only place where it's important,

    Colin

  • trongarttrongart Posts: 222Questions: 51Answers: 0

    @kthorngren @colin This works in stateLoadParams. Thank you very much!

Sign In or Register to comment.