Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81728

How can I reload data in datatable after doing any CRUD operation?

$
0
0

Hi,
I am developing an eletron app that uses a sqlite database. I use a query to fetch data and populate table data using its results. Whenever I do a CRUD operation I initialize table but despite change in database, no change in table data is occurred.
I use below code to populate table:

window.getData = function() {
  var db = require('./database/database');

  const results = db.prepare('SELECT name, family, mobile FROM customer').all();

  var html = '';

  for (const row of results) {
    html += '<tr>';
    html += '<td>';
    html += row.name;
    html += '</td>';
    html += '<td>';
    html += row.family;
    html += '</td>';
    html += '<td>';
    html += row.mobile;
    html += '</td>';
    html += '</tr>';
  }

  console.log(results);

  document.querySelector('#table_id > tbody').innerHTML = html;
};

and following to configure datatable:

$('#table_id').DataTable({
      retrieve: true
    });

Is there any way to reload data in datatable for my case?

Thanks in advance


Viewing all articles
Browse latest Browse all 81728

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>