Reputation: 6552
Using ajax.relaod
isn't updating the value that is being passed to the controller.
The variables have the correct values each time when entering the function but I'm not sure how to get reload to also see/accept the updated variables.
Do I need to destroy and rebuild the table each time?
if (!$.fn.DataTable.isDataTable('.workorder-table')) {
$('.workorder-table').DataTable({
"initComplete": function () {
hidePleaseWait();
},
rowCallback: function (row, data, index) {
--row classes added here based on data
},
columns: [
{ "data": "Facility", "name": "Facility", "title": "Facility" },
{ "data": "ShortDescription", "name": "ShortDescription", "title": "Short Description" },
{ "data": "Created", "name": "Created", "title": "Created" },
{ "data": "Completed", "name": "Completed", "title": "Completed" },
{ "data": "Status", "name": "Status", "title": "Status" }
],
ajax: {
url: "/Facility/WorkOrderSearch",
type: "POST",
data: { status: $('#Status').val(), facilityID: $('#FacilityID').val(), quickView: $('#QuickView').val() }
},
-- options here
});
} else {
$('.workorder-table').DataTable().ajax.reload(hidePleaseWait);
}
Upvotes: 3
Views: 3049
Reputation: 85518
If data
is turned into a function that can be executed
data: function(data) {
data.status = $('#Status').val();
data.facilityID = $('#FacilityID').val();
data.quickView = $('#QuickView').val();
}
Then this function will be executed upon each request, i.e when ajax.reload()
is called.
Upvotes: 7