Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

abhisheknayak_1111's avatar

After updating datatables.net in package.json, getting Uncaught TypeError: this.fnSettings is not a function error. How do I fix it?

After updating datatables.net to a newer version in my package.json, I'm encountering the following error:

Uncaught TypeError: this.fnSettings is not a function at C.fn.init.fnDrawCallback (backend.js...

It looks like the fnSettings method is no longer available in the updated version of DataTables. I tried to use this.settings() instead, but I'm still unsure if I’m handling it correctly.

Could someone guide me on how to properly update the callback function and replace deprecated methods like fnSettings? Any advice on other potential changes needed after updating datatables.net would be greatly appreciated!

0 likes
6 replies
RemiM's avatar
RemiM
Best Answer
Level 16

The fnSettings() method was removed in newer versions of DataTables, and the correct way to access settings now is through table.settings(). However, based on your error message, you might also be using other outdated methods that need to be updated.

Steps to Fix the Issue:

1 - Update fnSettings() to table.settings().

2 - Check for Other Deprecated Methods

Some older DataTables methods have been replaced with newer equivalents:

  • fnDraw()draw()
  • fnDestroy()destroy()
  • fnFilter()search()
  • fnGetNodes()rows().nodes()
  • fnClearTable()clear().draw()

3 - Modify fnDrawCallback

If your fnDrawCallback is still using outdated methods, update it:

$('#example').DataTable({
    drawCallback: function () {
        var api = this.api();
        console.log(api.settings()); // New way to get settings
    }
});

4 - Ensure You Have the Latest Compatible DataTables Plugins

If you're using additional DataTables plugins (like Buttons, Responsive, Select, etc.), they also need to match your updated DataTables version. Run:

npm list datatables.net

and update any mismatched dependencies.

Lastly, don't hesitate to read the offical documentation: https://datatables.net/upgrade/2#Legacy-API

abhisheknayak_1111's avatar

@RemiM Thanks for your help but this is auto generated file in public folder where I am getting the error.

abhisheknayak_1111's avatar

backend.js is auto generated why would i need to replace manually can anyone please help me to understand this..thanks in advance

RemiM's avatar

@abhisheknayak_1111 I'm assuming that you're not familiar with how the assets are built.

In short, when you run npm run build, the build folder within public is generated automatically. However, since you've updated datatables.net version in your package.json, you'll need to adjust your codebase accordingly. Once you've made the necessary updates, the next time you build your assets, the errors should be resolved.

That said, before running the build process, make sure your project is working correctly in development mode by using npm run dev and checking your terminal and web browser's dev tools.

Updating a package with breaking changes:

  1. Modify package.json to specify the desired package version.
  2. Update your codebase to accommodate any API changes introduced by the new version, ensuring everything works correctly in development mode.
  3. Once your local development environment runs without errors, execute npm run build to generate production-ready assets.
  4. Verify functionality in your browser—at this stage, no npm processes should be running, as your assets are already built, and your application should be fully operational.
1 like
RemiM's avatar

@abhisheknayak_1111 Glad I could help! If this solves your issue, please mark the thread as solved by marking the answer that helped you.

Please or to participate in this conversation.