How to use the datatables API without rendering the table?

How to use the datatables API without rendering the table?

YOMYOM Posts: 53Questions: 22Answers: 1

Hi there,

I'm looking to see if it's possible to initialize a datatable class without actually rendering a table.

My application uses server-side processing in Node and I've recently made it such that the user can add or remove columns, which are then added or removed from the SQL query on the backend to help reduce latency.

Unfortunately, we have a need for the editor forms to include data that is not currently in the datatable. Because the two classes are tightly coupled, I've needed to create separate instances of both specifically for managing the edit / create forms without affecting the user's table display.

I'm curious if there is a way to initialize the DataTable such that no DOM manipulation is required?

Here is my initialization call:

const createDatatable = (columns) => {

  return $("#temp-dt-edit-table").DataTable({
    ajax: {
      url: `${baseURL}/datatables/main`,
      contentType: "application/json",
      type: "POST",
    columns: columns,
    options: {
      pageLength: 1,
      paging: true,
      serverSide: true,
      dom: "", // dom option to disable HTML render?

This question has an accepted answers - jump to answer


  • allanallan Posts: 61,603Questions: 1Answers: 10,084 Site admin
    Answer ✓

    At this time no, sorry. It is something I've thought about in the past, but I keep coming back to the fact that there are already so many ways to manipulate data other than the DataTables API, that it probably isn't worth implementing. DataTables uses the DOM to store information, as well as its Javascript memory cache, so separating them isn't a simple operation I'm afraid.


  • YOMYOM Posts: 53Questions: 22Answers: 1

    No worries, thank you for the answer and all the work you do Allan

Sign In or Register to comment.