DataTables warning: table id=employeeTable - Requested unknown parameter 'lang' for row 0, colum 1

DataTables warning: table id=employeeTable - Requested unknown parameter 'lang' for row 0, colum 1

vedantvedant Posts: 3Questions: 1Answers: 0

I am using datatables to fill data into the table in jsp using response from Java.
I randomly keep getting alert message saying 'DataTables warning: table id=employeeTable - Requested unknown parameter 'lang' for row 0, column 1. For more information about this error, please see http://datatables.net/tn/4'.

Data is received from Java backend successfully, but this alert pops up randomly(not all the time).

Below is the code that I am using in jsp to fill data in employeeTable table-

function insertRecInTable(URL) {
    var smsUplaodTemplateTable = $("#employeeTable").DataTable({
        "bServerSide": true,
        "sAjaxSource": URL,
        "bProcessing": true,
        "sPaginationType": "full_numbers",
        "bJQueryUI": false,
        "scrollY": "650px",
        "scrollX": true,
        "scrollCollapse": true,
        "fixedColumns": true,
        "bAutoWidth": false,
        "async": false,
        "aoColumns": [
                    { "mDataProp": "empId", "sClass": "textCenter" },
                    { "mDataProp": "lang", "sClass": "textCenter" },
                    { "mDataProp": "content" },
                    {
                      "mDataProp": null,
                      "sClass": "textCenter",
                      "orderable": false,
                      "mRender": function(data, type, full) {
                                    return "<button id='showListBtn'>Show List</button>";
                                 }
                    }
              ]
    });
}

This method works perfectly and fills the data in the table but alert message pops up at some times.
Did I also use "async": false correctly?
I am new to datatables, any help is appreciated.

Answers

  • kthorngrenkthorngren Posts: 20,275Questions: 26Answers: 4,765
    edited June 2022

    Just for reference as this is not the problem. You are using some legacy option names like aoColumns which is now columns. The legacy names are supported. This page shows the conversion from legacy to the current naming convention.

    Have you followed the troubleshooting steps at the URL in the error?
    http://datatables.net/tn/4

    The error indicates that your data doesn't always have the lang object as part of the row data. If this is expected you can use defaultContent to show a default value in that column if the object is not there. If this is not expected then you will need to troubleshoot your server script to find out why the data is missing.

    Did I also use "async": false correctly?

    Datatables doesn't have an async option. If you are trying to make the Ajax request asynchronous then you will need to use the ajax option instead of sAjaxSource. However setting async false for Ajax is not recommended. Why do you want to do this?

    Kevin

  • vedantvedant Posts: 3Questions: 1Answers: 0
    edited June 2022

    Hi kthorngren, I changed the legacy option names and tried to run the code, now it is not working at all.
    And the 'lang' object in always fetched from the query and the response is always available from java to jsp.
    I also tried troubleshooting steps from the URL in the error but that did not help.
    Here is my code after changing legacy option names.

    function insertRecInTable(URL) {
        var smsUplaodTemplateTable = $("#employeeTable").DataTable({
            "serverSide": true,
            "ajax": URL,
            "processing": true,
            "pagingType": "full_numbers",
            "jQueryUI": false,
            "scrollY": "650px",
            "scrollX": true,
            "scrollCollapse": true,
            "autoWidth": false,
            "columns": [
                        { "data": "empId", "className": "textCenter" },
                        { "data": "lang", "className": "textCenter" },
                        { "data": "content" },
                        {
                          "data": null,
                          "className": "textCenter",
                          "orderable": false,
                          "render": function(data, type, full) {
                                        return "<button id='showListBtn'>Show List</button>";
                                     }
                        }
                  ]
        });
    }
    

    The reason for putting 'async' was that I thought that UI table is getting displayed before getting the response from Java and hence causing the alert sometimes.

    Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    You have server-side processing enabled - does whatever URL points to fully implement server-side processing?

    If you link to the page we'll be able to diagnose the issue and they you know what is causing it.

    Allan

  • vedantvedant Posts: 3Questions: 1Answers: 0

    Hi Allan,
    URL is pointing to Java class which in turn calls Rest API to fetch data from the DB to display in the table

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    Thanks - however, I'm afraid that doesn't answer my question. Does that REST API implement server-side processing? If not, remove that option.

    As I say, if you give me a link to the page I'll be able to help more. Otherwise, and without more information, I'm really just guessing.

    Allan

Sign In or Register to comment.