Title: Reset/Clear Search Button
Last modified: August 22, 2016

---

# Reset/Clear Search Button

 *  Resolved [dmurphyca](https://wordpress.org/support/users/dmurphyca/)
 * (@dmurphyca)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/resetclear-search-button/)
 * Hi Tobias,
 * First, big thanks for making this plugin.
 * Second, I’m trying to come up with a solution for implementing a Reset/Clear 
   button for the search bar. I know you’ve addressed this issue in the past in 
   this [thread](http://wordpress.org/support/topic/add-a-clear-and-a-reset-buttons-around-a-search-form?replies=4)
   and did not know of a clear solution.
 * I’ve found a couple of posts on the datatables.net forum discussing this:
    1.
   [Search input field – reset button](https://datatables.net/forums/discussion/480/search-input-field-reset-button)
   2. [clear search button](https://datatables.net/forums/discussion/15399/clear-search-button)
 * Is it possible to implement one of these solutions into the TablePress plugin
   too? And if so, do you know where to get started. I’m kind of at a loss for where
   to insert some of the suggested code.
 * If these solutions are not possible though, my backup plan is to create a hyperlink
   button that just reloads the page. However, I’d like the hyperlinked text “Reset”
   to be in close proximity to the Search bar.
 * I used some CSS you provided in another [thread](http://wordpress.org/support/topic/move-search-box-location?replies=12)
   to move the Search bar over the the left side of the page, but since I’m also
   using the Drop Down menus from the ColumnFilters widget I don’t know how to get
   the Search bar above the Drop Down menus. If I was able to do that I could get
   a hyperlink right above the Search bar, although it would be best to have it 
   to the right of the Search bar, but I’m not sure how to do that either.
 * Sorry to pose so many questions but wanted to pick your brain in case you knew
   any workarounds. Any help would be greatly appreciated. And thank you again for
   all the work on this plugin.
 * FYI: Here is a link to the test page I’m working on for this: [Active Searches](http://www.commonagenda.co/2014/?page_id=867)
 * Best regards,
 * Daniel Murphy
 * [https://wordpress.org/plugins/tablepress/](https://wordpress.org/plugins/tablepress/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/resetclear-search-button/#post-5195657)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * A quick solution might be this: Please try adding this code to the “Custom Commands”
   textfield on the “Edit” screen of the table:
 *     ```
       "fnInitComplete": function(oSettings, json) { $( '.dataTables_filter input' ).attr( 'type', 'search' ); }
       ```
   
 * That will turn the search field into an actual “Search” field, which will have
   a small “x” button inside it, once a user has typed something in, and clicking
   that will reset the field.
    We will see this more and more in the future, as 
   that’s part of the HTML5 standard.
 * Regards,
    Tobias
 *  Thread Starter [dmurphyca](https://wordpress.org/support/users/dmurphyca/)
 * (@dmurphyca)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/resetclear-search-button/#post-5195658)
 * Hi Tobias,
 * Thank you for getting back to me. I added the Custom Command and the x button
   appears in HTML5 supported browsers. However, my goal is to reset the table so
   that after a search is cleared the table reverts to the regular data cells. Right
   now if you use the search and clear it, then the table keeps whatever came up
   from the search. Do you know if it’s possible to have this x button reset the
   table data too?
 * Also, is there a way to move the Drop Down menu from the Column Filter Widget
   plugins to the same line as the Search and Entries bars? Ideally I’d like to 
   have the Drop Down menu for “Location” after the Search bar.
 * Thank you again for helping me so far, much appreciated. Let me know if you can
   think of any workarounds for these issues.
 * Best,
 * Daniel
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/resetclear-search-button/#post-5195659)
 * Hi Daniel,
 * ah, bummer. You are right, this does only empty the search field, but it does
   not reset the filtering…
 * You might then have to use some custom JavaScript (similar to some of what is
   those links that you posted) on the page directly, i.e. in `<script>` tags that
   you paste below the `[table]` Shortcode.
    (If you are interested in my personal
   opinion: I’m not sure if users aren’t smart enough to recognize that manually
   clearing the “Search” field will get them back to the full table. So, I wouldn’t
   put too much energy into finding a solution here.)
 * Regarding the position of the Column Filter Widgets: Due to how that is added
   to the “DOM” in the browser, you would need some rather sophisticated CSS to 
   reposition those drop downs (which I don’t have readily available). You would
   most likely also run into issues with things sudddenly shifting on the page, 
   when a user selects something from the dropdown, which again can look ugly).
 * Regards,
    Tobias
 *  Thread Starter [dmurphyca](https://wordpress.org/support/users/dmurphyca/)
 * (@dmurphyca)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/resetclear-search-button/#post-5195663)
 * Hi Tobias,
 * Thank you for the quick reply.
 * I see that [this person](http://live.datatables.net/equwes/20/edit) accomplished
   a reset of the filtering with a search clear button. That’s exactly what I’m 
   looking for. However I haven’t figured out how to implement their code.
 * And if I can’t move the Column Filter Widgets (and I now see the potential problems
   when users start making selections) is there a way to move my hyperlink “Reset”
   next to the Search button? So far I’ve just included a hyperlink before inserting
   the Table Shortcode.
 * Thank you again for taking a look at all this.
 * Best,
 * Daniel
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/resetclear-search-button/#post-5195670)
 * Hi Daniel,
 * well, the “person” in that link just happens to be lucky: He’ already using a
   newer version of the DataTables JS library than the version that comes with TablePress.
   There’s however no direct code that we could copy here 🙁
    (I’m planning to integrate
   that new version of DataTables in the next version of TablePress though. This
   will take a couple more weeks though. Meanwhile, you could try to replace the
   JS file in TablePress with that from the DataTables website — or just wait until
   this feature becomes part of the plugin.)
 * Moving the “Reset” link next to the “Search” field suffers from the same problems
   as would moving the ColumnFilterWidgets dropdowns: It’s a different HTML element
   that simply is located in a different position in the DOM on the page 🙁
 * Regards,
    Tobias
 *  Thread Starter [dmurphyca](https://wordpress.org/support/users/dmurphyca/)
 * (@dmurphyca)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/resetclear-search-button/#post-5195676)
 * Thanks for the response Tobias. I think I’ll wait until you’ve integrated the
   new version of DataTables and hope that fixes it. I really appreciate all the
   work you’re doing with this plugin.
 * Best,
 * Daniel
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/resetclear-search-button/#post-5195693)
 * Hi Daniel,
 * yes, that’s probably going to be the easiest way here, and it would save you 
   some work.
 * Regards,
    Tobias

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Reset/Clear Search Button’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/resetclear-search-button/#post-5195693)
 * Status: resolved