Get search field content

Get search field content

dustybottomdustybottom Posts: 4Questions: 1Answers: 0
edited March 2013 in General
How can I get the search field content? I want to integrate the search field content in the filename of the exporting csv-File on tabletools. But I am not able to get the content of the search field with fnSettings().oPreviousSearch:
http://live.datatables.net/icowul/11/edit#javascript,html,live
In this case there is a preset on the search field "Ger"
"oSearch": {"sSearch": "Ger"}
In the 2nd footer cell the current "Searchtext content" should be displayed but Datatables stop working as soon as adding fnSettings().oPreviousSearch

Regards

Mike

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    Hi Mike,

    Thanks very much for the test page - really helpful for seeing exactly what you are trying to achieve.

    The reason the code wasn't working is that the settings object isn't actually passed into fnFooterCallback, possibly it should be, however, fnFooter callback is like all other DataTables callback function in that it is executed with the DataTables instance's scope. This is a fancy way of saying you call use the API methods by simply prefixing the call with `this` . For example, to getting the settings object you would use: `this.fnSettings()` .

    Extending that principle, to get the current search string into your footer cell you would use:

    [code]
    nCells[1].innerHTML = this.fnSettings().oPreviousSearch.sSearch;
    [/code]

    http://live.datatables.net/icowul/12/edit

    Regards,
    Allan
  • dustybottomdustybottom Posts: 4Questions: 1Answers: 0
    Thanks Allan. Works like a charme!
This discussion has been closed.