Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]TypeError: Cannot read properties of undefined (reading 'settings') at re insert table in version ^9.0.0 #375

Closed
2 tasks done
HiroyukiMakita opened this issue Mar 26, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@HiroyukiMakita
Copy link

HiroyukiMakita commented Mar 26, 2024

  • I have looked through the documentation to try to see if this behavior is documented.
  • I have looked at the demos to see if one of them handles this, but none of them did.

Describe the bug
I get an error when re-displaying a table with the following steps.

  1. insert
  2. destroy
  3. re insert
    error occurs

How to reproduce

I have created a StackBlitz here: https://stackblitz.com/edit/daisyui-vue-vite-wxwb7r?file=package.json,src%2FApp.vue to reproduce this issue.

Steps to reproduce the behavior

  • Run npm install && npm run dev in a terminal (if it does not run automatically)
  • Click UPDATE-TABLE on the screen that appears.
    The table will be displayed.
  • Click UPDATE-TABLE again.
    Now you will get an error in the console (TypeError: Cannot read properties of undefined (reading 'settings')).

View errors
Expected behavior
Each time you click UPDATE-TABLE, you expect to see the table redraw without error and the counter for no table change.

image

Other Situations

I have confirmed that the version ^8.0.1 installed by npm i simple-datatable@8 does not generate any errors.

@HiroyukiMakita HiroyukiMakita added the bug Something isn't working label Mar 26, 2024
@enriqc3
Copy link

enriqc3 commented Apr 2, 2024

I get the same error using CDN v9.0.0

@Monkey999Human
Copy link

I get also the same error

@ray-wn
Copy link

ray-wn commented Apr 10, 2024

I don't know if this workaround helps you @HiroyukiMakita @enriqc3 @Monkey999Human?
I set the data using data: { headings: headings, data: data }

I changed my <table id="myTable"></table> to <div id="myTable"></div>.
Now mytable.destroy() and doing mytable = new simpleDatatables.DataTable(tableElement, { myOptions }) works again.

Not sure if something isn't correctly reset or cached when using a table-element?
The ctor of the datatable contains:

if (dom instanceof HTMLTableElement) {
    this.dom = dom
} else {
    this.dom = document.createElement("table")
    dom.appendChild(this.dom)
}

So maybe because the table-element is created instead of using the existing one fixes it?

@johanneswilm
Copy link
Member

Fixed in version 9.0.1. Thanks for reporting @HiroyukiMakita!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants