TypeError: Cannot set properties of undefined (setting 'emptyTable')

TypeError: Cannot set properties of undefined (setting 'emptyTable')

prajwalrajprajwalraj Posts: 7Questions: 1Answers: 0
edited September 17 in Free community support

My project was earlier was using 1.10.1 which due to vulnerable we have decided to move at least up to 1.10.11. but facing this error when page loading:


jQuery v2.1.1 used here.

Anything to be updated here. Any help would be appreciated.

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    Even 1.10.11 is over 8 years old and no longer supported. 2.1.6 is the current release.

    You are using an internal property there. Anything inside the DataTables settings object is liable to change, even between minor versions. You should use i18n() to look up language tokens.

    Allan

  • prajwalrajprajwalraj Posts: 7Questions: 1Answers: 0

    @allan

    Thanks for quick response. This is like legacy code and migration to latest version is result in functionality break.

    It would be great if you help me in understanding how i18n() will help me in solving the current issue.

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    edited September 17 Answer ✓

    Oh - I misread the code. You are attempting to change an internal language property, which is not supported in any version of DataTables. I had thought you were getting the value before.

    Try oSettings.oLanguage.sInfoEmpty = .... Again, it might break between versions since what you are doing is not supported, but I expect that to work.

    Allan

  • prajwalrajprajwalraj Posts: 7Questions: 1Answers: 0

    Thanks for the help @allan .

    setting Settings.oLanguage instead of Settings.language solved the issue.

  • prajwalrajprajwalraj Posts: 7Questions: 1Answers: 0

    @allan

    Request you to help on below syntax as well.

    Further am getting this error


    Uncaught TypeError: n.fnSetColumnVis is not a function
    at m.resetTable (table.js:864:1)
    at m.init (table.js:400:1)
    at Q.init (report.js:263:1)
    at protocolsWeb.js:291:1
    at Object.execCb (requireLib.js:1659:1)
    at _.check (requireLib.js:875:1)
    at _.enable (requireLib.js:1152:1)
    at _.init (requireLib.js:783:1)


    Code used is:

    **dataTable.fnSetColumnSearchable(idx, false);
    **--------------------------
    tried updating code to :

    dataTable.column(idx).searchable(false);


    Still the error remains with:

    Uncaught TypeError: n.column(...).searchable is not a function

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Answer ✓

    fnSetColumnVis

    That was the name of the column visibility method in the legacy API (which was removed completely in v2). column().visible() is the method to use (as of 1.10 and newer).

    tried updating code to :
    dataTable.column(idx).searchable(false);

    As you'll see in the reference table there is no such method, so I'm not surprised you are getting an error.

    I don't know where "fnSetColumnSearchable" came from, but it was never part of the public API for DataTables. There is no way in the API to dynamically enable and disable the searchability of a column.

    Allan

  • prajwalrajprajwalraj Posts: 7Questions: 1Answers: 0
    edited September 24

    @Alan

    Thanks for assistance. You are right. They are not part of public API for data tables, but are extensions.

    Like below:

    $.fn.dataTableExt.oApi.fnSetColumnSearchable = function (oSettings, col, vis){
    ...
    }

    my dataTable is defined as :

    var dataTable = this.$dataTable.DataTable();// let me know if any case sensitive changes required

    This dataTable object do not have this function when printed it, which was not the case before migration. Is any extension feature is deprecated or updated?

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    fnSetColumnSearchable is not a plugin I'm aware of. Searching this forum finds nothing for it. Is it something you wrote yourself? It would need to be updated for v2 as the legacy API has been completed removed in v2. How to write your own API plugins is discussed here.

    As I say, dynamically changing the searchable attribute for a column is not something that is possible through the API at the moment. You would need to modify DataTables (possibly with just a plugin API method, but I'm not sure, as it isn't something I've looked into before) to make it work.

    Allan

  • prajwalrajprajwalraj Posts: 7Questions: 1Answers: 0

    Yes it looks like custom written and attaching it with datatable object.
    //function defination
    $.fn.dataTableExt.oApi.fnSetColumnSearchable = function (oSettings, col, vis){
    ...
    }

    //function call
    dataTable.fnSetColumnSearchable(idx, false);

    May be it was legacy way of registering functions to data table object.

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    It was yes. That was how it was done in 1.9 and earlier. 1.10 introduce the "new" API and since then that has been the recommended way. 1.x retained backwards compatibility for the old API, but it was removed complete in 2.0. Upgrade notes here.

    Allan

  • prajwalrajprajwalraj Posts: 7Questions: 1Answers: 0

    Thanks @allan for the assistance.

    var DataTable = $.fn.dataTable;
    var apiRegister = DataTable.Api.register;

    apiRegister( 'search.fnSetColumnSearchable()', function ( oSettings, col, vis ) {
    ...
    });

    and

    $.fn.dataTableExt.oApi.fnSetColumnSearchable(idx, false);

    Made the fix.

Sign In or Register to comment.