Don't Save Search State

Don't Save Search State

mkoenigmkoenig Posts: 4Questions: 0Answers: 0
edited January 2012 in DataTables 1.8
How do you go about not saving the search field. I want it to save sort, and item per page preferences, but not the searched data.

This causes an issue.

Thanks Datatables!

Replies

  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    Example in the documentation for 1.9 (currently in beta, although the release will be soon): http://datatables.net/docs/DataTables/1.9.beta.2/DataTable.defaults.html#fnStateSaveParams

    Allan
  • mkoenigmkoenig Posts: 4Questions: 0Answers: 0
    Hey thanks so much for the reply :)

    I added the data to the current script and it now reads

    [code]

    $(document).ready(function() {
    dTable = $('#example').dataTable( {
    "bStateSave": true,
    "fnStateLoadParams": function (oSettings, oData) {
    oData.oFilter.sSearch = "";
    }


    } );
    } );

    [/code]

    But this removes the searchbox and all the filtering/sorting.

    I upgraded to beta 1.9 of course :)

    Any idea?
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    Does your table have an ID of 'example'? Are you getting any script errors?

    It looks like it should be working to me :-)

    Allan
  • mkoenigmkoenig Posts: 4Questions: 0Answers: 0
    Lol yes it does i should change the name from example to something else and then change the corresponding dTable = $('#example')


    Ok, well i guess ill just wait for the full release no big deal. I really like the software :)
  • mkoenigmkoenig Posts: 4Questions: 0Answers: 0
    And thanks very much fro trying to help me :)
  • kshippkshipp Posts: 6Questions: 0Answers: 0
    edited September 2012
    I needed this same feature in the latest version.
    Another poster recommended this:
    There is a plugin that clears the DataTable filter here fnFilterClear
    http://datatables.net/plug-ins/api

    ....and it worked for me - using the latest version of Datatables and the plugin.
This discussion has been closed.