resetPaging issue when using callback function

resetPaging issue when using callback function

vgaxvsivgaxvsi Posts: 3Questions: 1Answers: 0

I have a DataTable that is working fine however whenever a user updated an item, the ajax.reload() would reset the paging as it does by default. This hasn't been an issue but now that we have a larger dataset, we want to stay on the page after the update is done.
The resetPaging is the solution but it isn't working as expected. After adding the resetPaging(false), it doesn't reset the paging but the page doesn't seem to reload either as the column data that should update doesn't. If I issue an ajax.reload() after the fact, I can confirm the column data did update correctly. Also, if I remove the resetPaging parameter, the paging resets but the table data is updated properly, I just need to manually go back to that page.
The reload call I'm using is
jobsDTRef.ajax.reload(dtTableReloadCallback, false);
and the callback function is;

function dtTableReloadCallback() {
    // reload custom filters
    jobsDTRef.columns([1, 2, 6]).every(
        function () {
            var column = this;
            var select = $('<select class="form-control"><option value=""></option></select>')
                .appendTo($(column.footer()).empty())
                .on('change', function () {
                    var val = $.fn.dataTable.util.escapeRegex(
                        $(this).val()
                    );

                    column
                        .search(val ? '^' + val + '$' : '', true, false)
                        .draw();
                });

            column.data().unique().sort().each(function (d, j) {
                select.append('<option value="' + d + '">' + d + '</option>')
            });
        }
    );

I tried adding a second ajax.reload(null,false) right after just to see if that affected anything but it didn't make any difference.

I am initializing the table as follows;
``` jobsDTRef = jobsDT.DataTable( {
rowId: 'file_id',
"ajax": 'api/v1/files?dt',
"processing": true,
lengthChange: false,
pageLength: maximum_rows_per_page_jobs_list,
autoWidth: false,
order:[[0,"desc"]],

    "columns": [ ...

```
Any suggestions would be appreciated.
Thx

Answers

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    Using ajax.reload() with a callback and false is working here:
    http://live.datatables.net/desemama/1/edit

    Have you used the browser's network inspector to verify the ajax request is sent with jobsDTRef.ajax.reload(dtTableReloadCallback, false);?

    Do you see errors in the browser's console?

    Can you provide a link to your page or a test case replicating the issue so we can help debug?
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • vgaxvsivgaxvsi Posts: 3Questions: 1Answers: 0

    @kthorngren I checked the network inspector but don't see the request either way, whether it is true or false but if set to true, the page reloads. There are no errors in the browser either.
    I have updated our dev environment with the change where you can replicate the issue.
    Once you login, go to page 8 of the list. You will see some records with action icons at the end;
    If you click the Eye icon,. this will open a popup with data. This action has the false added to the reload.
    If you click the Download icon, this will download an rtf. This reload function is set to default true.

    Site: test.vscription.com
    user: vstpacc1u01@vscription.com
    Can I DM you the password or is there somewhere else I can post it?

  • vgaxvsivgaxvsi Posts: 3Questions: 1Answers: 0

    @kthorngren I applied this to my server dev environment and it seems to be working. I wonder if it may just have been a performance issue with my local dev environment?
    Anyways, I'm going to test a bit more and will reach out if I need more help.

Sign In or Register to comment.