SKR
SKR

Reputation: 473

Adding a refresh button to jQuery Datatable

I have a dataTable in my application. I am required to add a Refresh button somewhere near Search textbox within the datatable in order to refresh the table when user clicks on it. I have figured out the refresh functionality.

The thing that I am stuck with is how do I include this button within the datatable? I want to access this button id in my end script.

Any suggestions? Also can anyone tell what is the use of bJQueryUI?

Upvotes: 12

Views: 24451

Answers (4)

devlife
devlife

Reputation: 16155

Here is the example page for adding buttons from datatables.net

http://datatables.net/examples/advanced_init/dom_toolbar.html

And here is the example page for sDom as mentioned by @Mike: http://datatables.net/release-datatables/examples/advanced_init/dom_multiple_elements.html

Upvotes: 4

SKR
SKR

Reputation: 473

I simply used the following code:

$('<button id="refresh">Refresh</button>').appendTo('div.dataTables_filter');

Upvotes: 28

Drakkainen
Drakkainen

Reputation: 1142

You could just make a double header and use the second one for a button.

bJqueryUI allows you to use jQueryUI themes or the theme roller. So if you add the jQueryUI before you initialize datatable you could use that style instead of the default one.

Upvotes: 0

Mike
Mike

Reputation: 781

I had a similar issue that I was able to solve using the sDom parameter of datatables.

http://datatables.net/forums/discussion/37/the-sdom-parameter/p1

Basically it allows you to place a div with an id within the datatable. I then used javascript to insert the button into that div.

Upvotes: 0

Related Questions