please help me, i'm very newbie i have question about datatables (jquery plug in).
at every rows data in datatables grid, I have button to delete data. when i click delete button, data at that row deleted.
the question is, can I refresh data table without reloading the page ? so the rows can be decrease when i click delete button without reloading the page.
this is my code: (just FYI my table id for datatble is: id="mydatatable")
html delete button on each rows data:
-------------------------------------
<button onclick="delete('id')">Delete</button>
javascript:
-----------
delete(id)
{
delete_ajax(id); //deleting data using ajax
window.location.reload() //reloading page, this what i want to change
//(just refresh datatable grid without reload the page)
}
many thanks :)
You will need to use a client-side scripting language such as javascript in order to be able to refresh certain contents on your HTML page. A very common library that is used is jQuery.
DataTables warns about the use of them by default, as the majority of the time they are not intended for display - for example, rather than showing null in the table, you might want to show Not yet set, or simply an empty string (empty cell). For this, DataTables has a columns. defaultContent option.
This is one of many ways to quickly refresh a table
const table=$("table.datatable").dataTable();
table.fnPageChange("first",1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With