datatables warning: table requested unknown parameter tableAlias.tableField

datatables warning: table requested unknown parameter tableAlias.tableField

ArianArian Posts: 6Questions: 3Answers: 0
edited January 2020 in Free community support

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 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 discussion has been closed.