Reload table with new data
Reload table with new data
BCKurt
Posts: 5Questions: 0Answers: 0
I load a table with some JSON returned from a .php file:
[code]
nvTable = $('#NV').dataTable( {
"bJQueryUI": true,
"sDom": 'T<"clear">lfrtip',
"bAutoWidth": false,
"aoColumns": [
{"sWidth": "15%"},
{"sWidth": "10%", "sType": "numeric"},
{"sWidth": "15%", "sType": "numeric"},
{"sWidth": "60%"},
],
"iDisplayLength": 25,
"bProcessing": true,
"sAjaxSource": "makeTable.php?type=NV"
} );
[/code]
I have a combobox that allows the user to specify a model to display. I want to pass that along to makeTable.php to create a different table with some different data:
[code]
$("#NVBox").change(function() {
var model = $("#NVBox option:selected").text();
$.ajax({
type: "GET",
url: "makeTable.php",
data: ({type: "NV", model: model}),
cache: false,
dataType: "json",
success: function(json) {
nvTable.fnClearTable(0);
nvTable.fnAddData(json);
}
});
});
[/code]
However, this gives me the following error:
DataTables warning (table id = 'NV'): Requested unknown parameter '0' from the data source for row 0
My makeTable.php file checks to see if model is set, if not, then it returns everything. If it finds the model, then it only returns those along with the price for the model (left out in the main table).
Any ideas?
[code]
nvTable = $('#NV').dataTable( {
"bJQueryUI": true,
"sDom": 'T<"clear">lfrtip',
"bAutoWidth": false,
"aoColumns": [
{"sWidth": "15%"},
{"sWidth": "10%", "sType": "numeric"},
{"sWidth": "15%", "sType": "numeric"},
{"sWidth": "60%"},
],
"iDisplayLength": 25,
"bProcessing": true,
"sAjaxSource": "makeTable.php?type=NV"
} );
[/code]
I have a combobox that allows the user to specify a model to display. I want to pass that along to makeTable.php to create a different table with some different data:
[code]
$("#NVBox").change(function() {
var model = $("#NVBox option:selected").text();
$.ajax({
type: "GET",
url: "makeTable.php",
data: ({type: "NV", model: model}),
cache: false,
dataType: "json",
success: function(json) {
nvTable.fnClearTable(0);
nvTable.fnAddData(json);
}
});
});
[/code]
However, this gives me the following error:
DataTables warning (table id = 'NV'): Requested unknown parameter '0' from the data source for row 0
My makeTable.php file checks to see if model is set, if not, then it returns everything. If it finds the model, then it only returns those along with the price for the model (left out in the main table).
Any ideas?
This discussion has been closed.
Replies
Allan
nvTable.fnReloadAjax('generateTableData.php?type=NV');
And having the fnReloadAjax JS code above the table initialization.
Thanks.