datatables warning: table requested unknown parameter for data like tableAlias.tableField
datatables warning: table requested unknown parameter for data like tableAlias.tableField

This error is happening because the query that returns the data is in the form of:
SELECT A.FIRST, A.LAST FROM TABLE A
So it is returning A.FIRST
and A.LAST
and while showing the data in the datatable above error is showing.
I have the table header and data dynamic since different queries returning different results can be executed.
var table_columns = [];
$.each(data[0], function(key, value) {
var column_item = {};
column_item.data = key;
column_item.title = key;
table_columns.push(column_item);
});
var table = $("#queryResult").DataTable({
destroy: true,
scrollX: true,
data: data,
"columns": table_columns,
"paging": true
});
The workaround to fix this is to add an alias to the query to prevent returning tableAlias.tableField
like below:
SELECT A.FIRST AS FIRST, A.LAST AS LAST FROM TABLE A
Is there any other way to prevent that error from happening other than changing the query?
This question has an accepted answers - jump to answer
Answers
See if the Nested Objects example helps.
Kevin
Hi kthorngren, in my case I need datatables to read
A.FIRST
as a value not as a nested object.Can you paste a few rows of your data, please, it'll help us to understand the format.
Colin
Hi colin, I think data itself is not the issue, but the way datatable is processing the data which is like a nested object because of the A.FIRST column name. Anyways here is a sample row of information:
Is that the Ajax data, or your database? We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Colin
You gave me an idea @colin, I'm doing the below to get the header value in the controller:
that is returning for the Ajax Call in the key the column name as I have it in the query
A.FIRST
, and that's what is causing the issue with the datatable. So I will remove theA.
from here not to have that issue and not to add alias in the queryThanks!