What I'm trying to do is to do an ajax search to a datatable. I'm not considering the default search functionality provided by datatables for some reasons, so I created a textbox with a button for it.
On my Api, I'm sending back a Json for the javascript function
$("#buttonSearchDevice").on('click', function () {
var searchString = $("#searchString").val();
$.ajax({
url: "/Devices/LoadDevices",
type: "GET",
contentType: "application/json; charset=utf-8",
dataType: "json",
data:
{
searchString: searchString
},
success: function (data) {
//if (data.length == 0)
// $('#devicesList').dataTable().fnClearTable();
//else {
// $('#devicesList').dataTable().fnClearTable();
// $('#devicesList').dataTable().fnAddData(data);
//}
}
});
});
I tried the commented code to "refresh" my datatables, but no success, I'm getting the following error:
DataTables warning: table id=devicesList - Requested unknown parameter 'model' for row 0, column 1. For more information about this error, please see http://datatables.net/tn/4
Do I need to recreate the entire datatable (destroy and create) or is possible to just refresh it with the new comming data?