How to modify request data to refresh DataTable?

How to modify request data to refresh DataTable?

delishendelishen Posts: 1Questions: 1Answers: 0

I have a drop down list, and when users select a value from a drop down list, I want the data table refreshed based on newly selected value. The servlet will create the data based on the value passed in from client. I could not make it work, here is my code:

var objName = $(obj2Click+" option:selected").val(); // user selection
if ($.fn.dataTable.isDataTable(myTableId)) {
table = $(myTableId).DataTable();
//Question is how to pass the newly selected value objName to the ajax.data object, so that
// The data table will be refreshed based on new ObjectName = objName, the initial selection works fine, but change
// selection won't change the data. What is the proper way to alter ajax.data() so that the table can be refreshed? I can
// destroy the table, and reinitialize it, then it works fine.
table.ajax.reload(function(objName) {
ObjectName=objName;
});
table.draw();
} else {
table = $(targetId).dataTable({
dom: 'T<"clear">lfrtip',
"pagingType": "full_numbers",
"Processing": true,
"ajax": {
"url": "CcrQuery",
"type": "POST",
"data": {"ObjectName":objName}
}
});
}

This discussion has been closed.