Refresh Datatable
Refresh Datatable
ramyat
Posts: 1Questions: 0Answers: 0
Hi,
I have an issue on refreshing datatables. I used fnClearTable() to clear the datatable but it didn't work.
Basically I have two dropdowns with values and two buttons "Search" and "Reset". When 2 dropdown values are selected and hit "Search" button it displays datatable with data/records. Now when I hit "Reset" button it supposed to clear the values in the dropdown as well as the datatable. The datatable should pretty much be empty with no records but with just column names. Here is the code, and I am using Jquery datatables 1.9.4.
//buttons
//datatable
Search Results
// Search func
function searchClick(){
if (!isValidNonEmptyGuid($("#ContractID").val())) {
alert("Please select a Contract.");
return;
}
else if (!isValidNonEmptyGuid($("#ServiceLevelID").val())) {
alert("Please select a Proposed Service Level.");
return;
}
rebindGrid()
}
//Datatable initialization
jQuery(document).ready(function ($) {
var dataTable = LAMP.BaseDataTable.extend({
tableId: '@Model.ReportTableId',
additionalParams : function () {
return {
'contractID': $('#ContractID').val(),
'proposedServiceLevelID': $('#ServiceLevelID').val(),
'currentServiceLevelID': $('#AddServiceLevelID').val()
};
},
exportUrl: '@Url.Action("__GridDataCSV", "ContractCostAnalysis", new { area = "Reports" })',
baseUrl: '@Url.Content("~/")',
buttons: [
'columns',
'export',
]
}, {
"aoColumns": @Html.Raw(Model.ColumnSettings),
"sAjaxSource": "@Url.Content("~/Reports/ContractCostAnalysis/__GridData")",
"bServerSide": true,
"sScrollY": "300px",
});
LAMP.Report.LAMPDataTable = dataTable;
});
//Rebind Grid func
function rebindGrid() {
var table = $('#@Model.ReportTableId').dataTable();
table.fnReloadAjax();
}
//Reset func
function resetSearch() {
$("#ContractID").val("");
$("#ServiceLevelID").val("");
var oTable = $('#@Model.ReportTableId').dataTable();
oTable.fnClearTable();
}
Please take a look and let me know if I have gone wrong somewhere in the code.
Thanks in Advance !!
I have an issue on refreshing datatables. I used fnClearTable() to clear the datatable but it didn't work.
Basically I have two dropdowns with values and two buttons "Search" and "Reset". When 2 dropdown values are selected and hit "Search" button it displays datatable with data/records. Now when I hit "Reset" button it supposed to clear the values in the dropdown as well as the datatable. The datatable should pretty much be empty with no records but with just column names. Here is the code, and I am using Jquery datatables 1.9.4.
//buttons
//datatable
Search Results
// Search func
function searchClick(){
if (!isValidNonEmptyGuid($("#ContractID").val())) {
alert("Please select a Contract.");
return;
}
else if (!isValidNonEmptyGuid($("#ServiceLevelID").val())) {
alert("Please select a Proposed Service Level.");
return;
}
rebindGrid()
}
//Datatable initialization
jQuery(document).ready(function ($) {
var dataTable = LAMP.BaseDataTable.extend({
tableId: '@Model.ReportTableId',
additionalParams : function () {
return {
'contractID': $('#ContractID').val(),
'proposedServiceLevelID': $('#ServiceLevelID').val(),
'currentServiceLevelID': $('#AddServiceLevelID').val()
};
},
exportUrl: '@Url.Action("__GridDataCSV", "ContractCostAnalysis", new { area = "Reports" })',
baseUrl: '@Url.Content("~/")',
buttons: [
'columns',
'export',
]
}, {
"aoColumns": @Html.Raw(Model.ColumnSettings),
"sAjaxSource": "@Url.Content("~/Reports/ContractCostAnalysis/__GridData")",
"bServerSide": true,
"sScrollY": "300px",
});
LAMP.Report.LAMPDataTable = dataTable;
});
//Rebind Grid func
function rebindGrid() {
var table = $('#@Model.ReportTableId').dataTable();
table.fnReloadAjax();
}
//Reset func
function resetSearch() {
$("#ContractID").val("");
$("#ServiceLevelID").val("");
var oTable = $('#@Model.ReportTableId').dataTable();
oTable.fnClearTable();
}
Please take a look and let me know if I have gone wrong somewhere in the code.
Thanks in Advance !!
This discussion has been closed.
Replies
Allan