Reputation: 4708
I'm using the Javascript Datatable with server side searching.
So:
var table = $('#myTable').DataTable({
responsive: true,
serverSide: true,
ajax: {
url: myUrl,
dataSrc: ''
},
fnServerData: function (sSource, aoData, fnCallback, oSettings)
{
oSettings.jqXHR = $.ajax({
url: myUrl,
success: function (json, status, xhr) {
//Do stuff
}
});
}
});
I build the url dynamically using options set on my form.
I would like a button on my form so I can manually trigger the fnServerData function. At the moment I have to type into the included search box.
e.g. <button ng-click="model.search()">Search</button>
Is this possible?
Thanks
Upvotes: 1
Views: 6317
Reputation: 13161
With the latest DataTable, you need to use following in order to trigger server side call:
table.draw();
Upvotes: 1
Reputation: 247
Here is the code that I used for refresh the DataTable
var table = $("#gridId").dataTable();
//if you want to add extra parameters in the query
/*table.fnSettings().ajax.data = function (d) {
$.extend(d, jsonPostData);
};
*/
table.fnDraw(false);
Upvotes: 4
Reputation: 4708
I've found a solution:
var oTable = $('#myTable').dataTable();
oTable.fnFilter('');
Upvotes: 3