Datatable component does not refresh after new data is added


Topic: Datatable component does not refresh after new data is added

alana_vue pro asked 2 weeks ago

Hello, I am using the datatable 2 component, the data is being passed through an API. The data passed to the datatable is not static so that i will increase as the user add more data to the database. I have found 2 issues: 1.-) If the table columns are not predefined, the component will not render any column.
2.) When new data is added to the table (new rows), the component is not acting reactively and the component is not displaying the new information Expected behavior When new row data is added, the datatable must render the new data Actual behavior when new row data is added nothing happen Resources (screenshots, code snippets etc.)


Mikołaj Smoleński staff commented 2 weeks ago

Hi there,

Have you tried using a refresh property in this case? Here are some examples of using datatables with external API: https://mdbootstrap.com/docs/vue/tables/datatables/#external-api

Best regards


alana_vue pro commented 2 weeks ago

Hello!!! Thanks for your prompt reply. Yes, I am using the refresh property in the datatable. I am following the examples from the documentation as per the link you mentioned. Here the properties I am using. Thank you


Mikołaj Smoleński staff commented 2 weeks ago

There is also an option to add a reactive property for reloading data systematically in the given intervals (for example "time="2000"). Does that also not fix the problem?

Best regards


alana_vue pro commented 3 days ago

I am using reactive following the example on the website but nothing happens. here below are all the options I am using. The workaround I found is to use :key to update any dummy variable and trigger the refresh.

/>

alana_vue pro commented 2 days ago

I am noticing I'm getting the following error: Error in mounted hook: "TypeError: Cannot read property 'field' of undefined" I saw in an old post about this issue being corrected but apparently it's not


Please insert min. 20 characters.
Status

Open

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: Vue
  • MDB Version: 6.7.2
  • Device: PC
  • Browser: Chrome
  • OS: Windowns10
  • Provided sample code: No
  • Provided link: No