On Creation - refresh the page / datatable
On Creation - refresh the page / datatable
BalaKrishnanDhanuskodi
Posts: 45Questions: 17Answers: 0
in Editor
Happy Evening All,
Following is the code used to create, edit and delete inside a datatable. Looking at adding refresh option to the page/table every time when create button is used. Tried following code no result, any help would be grateful.
Code used to create:
var table = $('#issue_manager').DataTable( {
dom: 'Bfrtip',
ajax: 'DataTablesEditor/php/table.issue_manager.php',
columns: [
{
"data": "iss_no"
},
{
"data": "iss_summary"
},
{
"data": "iss_description"
},
{
"data": "iss_staus"
},
{
"data": "iss_raised_by"
},
{
"data": "iss_raised_by"
},
{
"data": "iss_last_update"
},
{
"data": "iss_assigned"
}
],
select: true,
lengthChange: false,
buttons: [
{ extend: 'create', editor: editor },
{ extend: 'edit', editor: editor },
{ extend: 'remove', editor: editor }
]
} );
Option 1
$(document).on('click', '#refreshdates', function(dn) {
$('#issue_manager').DataTable().ajax.reload();
});
$(document).on('click', '#cleardates', function(dn) {
$('#startdate').val("");
$('#enddate').val("");
$('#issue_manager').DataTable().ajax.reload();
});
Option 2
$('#issue_manager').DataTable().ajax.reload();
Also, I am not sure on how and where to place this code, so that it will get execute when 'create' button is used.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Are you also using Editor? The use of
editor: editor
in the configuration suggests that, but I don't see anything else indicating Editor is being used.Allan
Yes Allan, thanks for the suggestion and was able to figure out. Currently using following code.
Now this option is reloading entire page, so the datatable page navigation goes to first page; how can I avoid this ?
However, that really shouldn't be required. The new data should be entered into the table automatically, assuming you are returning the data correctly from the server.
Allan