I just want to ask how can datetimepicker be triggered on the next page of a data table? It is working correctly in the first page as seen in this screenshot.
But when I go now to the next page, the calendar is not triggered anymore:
Some suggested to re-initialize which I added like this:
var table = $('#ot_dataTables').DataTable();
$('#ot_dataTables').on( 'page.dt', function () {
$('#ot_dataTables').dataTable({
order: [[ 0, "desc" ],[ 2, "desc" ]]
});
} );
But still the calendar is not showing. Any help is appreciated.
Thanks a lot in advance.
I know its late but for others might facing this issue, use
draw.dt
instead ofpage.dt
. Whenever the datatable is drawn, the event fires.page.dt - Page change event - fired when the table's paging is updated.
draw.dt - Draw event - fired once the table has completed a draw.
I faced the same problem for the datetimepicker in the datatable. I added one code snippet to fix the issue. Here I have added details below:
HTML code:
I already had the code for the datetimpicker like the following(before adding datatable):
I added another code snippet so that it works same on the next page of pagination.
Following code I added for fixing the datetime picker not appearing on the next pages of Pagination
So this is similar to Senjuti's answer, but I wanted to post mine because I was able to do it without the need of recreating the table instance. However, she is right that a listener on
page.dt
won't work in this case but a listener ondraw.dt
will.In my answer, I'll use your table as an example and assume that
input
tags in the table have the class namedate-field
. What worked for me was recallingdatepicker()
on the input tags like so,