This topic contains 17 replies, has 2 voices, and was last updated by Jai Jai 2 months ago.

Refresh datatable doesn't work


  • eko
    Participant

    Posts: 109
    Member Reply #17279

    Hi i use datatable like this

    if (result.value) {
    $.ajax({
    url: “/admin/employee/destroy”,
    type: “POST”,
    success: function (data) {
    swal({
    type: ‘success’,
    title: ‘Your work has been saved’,
    timer: 4000
    }).then((reload) => {
    location.reload()
    })
    }
    })
    }

    when i change location.reload() into datatable.reload() it seem data is doesn’t change. it different when i use location.reload() so how can i fix it? thanks.

    • This topic was modified 3 months, 2 weeks ago by  eko.
    Jai
    Jai
    Keymaster

    Posts: 2627
    Support Staff Reply #17285

    Hi 🙂

    In your delete request, you already remove the data from your backend?

    Are you using remote source datatable? The datatable should be reloaded by request a new data and re-render everything.

    Can you send your datatable initialize code?

    Thanks


    eko
    Participant

    Posts: 109
    Member Reply #17327

    Hi, yes i already remove in the backend, it works when i just using location.reload. is it initial like this?

    data: {
    type: ‘remote’,
    source: ‘/management/deploy/table’,
    pageSize: 10,
    },

    I’m not so sure about rerendering, i think it’s because it saved in the cache that why even when I use data table.reload it doesn’t work.

    • This reply was modified 3 months, 1 week ago by  eko.
    Jai
    Jai
    Keymaster

    Posts: 2627
    Support Staff Reply #17370

    Hi 🙂

    Can you send the full datatable init code?

    Thanks


    eko
    Participant

    Posts: 109
    Member Reply #17411
    This reply has been marked as private.
    Jai
    Jai
    Keymaster

    Posts: 2627
    Support Staff Reply #17469

    Hi 🙂

    If you trigger the reload, then check the request from network tab at the browser dev tools, does it shows the correct result?

    Thanks


    eko
    Participant

    Posts: 109
    Member Reply #17482

    Yes it show the correct response and have no problem. but seem like the data is not re-rendering again. it just flashing and nothing happen although data was successfully updated or deleted.

    Jai
    Jai
    Keymaster

    Posts: 2627
    Support Staff Reply #17542

    Hi 🙂

    If you are using remote data, are you handling pagination locally?

    Can you try to enable server paging?

    data.serverPaging: true,

    If the reload is work after serverPaging is enabled, seems might be an issue with the data reload when serverPaging is disabled. We will check on this issue.

    Thanks

    • This reply was modified 3 months ago by Jai Jai.
    • This reply was modified 3 months ago by Jai Jai.

    eko
    Participant

    Posts: 109
    Member Reply #17546

    You mean enable server-side paging like this?

    data: {
    type: ‘remote’,
    source: ‘/admin/certificate-type/table’,
    pageSize: 10,
    “serverSide”: true,
    },

    I can’t put your code anywhere, it makes my code error. and yes, it paging locally. I use exactly the code in default.php which in api_refrence folder for the server side with just a few changes that I’m sure it won’t change anything. For the client, I use the code that I have a post above.

    • This reply was modified 3 months ago by  eko.
    Jai
    Jai
    Keymaster

    Posts: 2627
    Support Staff Reply #17551

    Hi 🙂

    Yes under data option.

    Not serverSide:true, but can you try serverPaging:true?

    Thanks


    eko
    Participant

    Posts: 109
    Member Reply #17634

    it’s still not working yet, it just gives me flashing but not re-rendering the data.

    Jai
    Jai
    Keymaster

    Posts: 2627
    Support Staff Reply #17713

    Hi 🙂

    We have checked in the plugin code and did deep testing. For some reason there is a condition where JSON data source should be not updated on reload(); Now this condition is not needed anymore.

    Please check the attached image, just commented out at line 1120 in datatable.js plugin file.

    This patch and fix should be available in the next quick update.

    Thanks

    Attachments:
    You must be logged in to view attached files.

    eko
    Participant

    Posts: 109
    Member Reply #17789

    Ah ok, hope you guys add it on the next update. I use vendors.bundle.js I was too lazy to add one by one the plugin so it’s impossible for me to get the correct line.

    Jai
    Jai
    Keymaster

    Posts: 2627
    Support Staff Reply #17800

    Hi 🙂

    Okay, we have updated it in the source code. It will be officially released soon together with other updates.

    Thanks


    eko
    Participant

    Posts: 109
    Member Reply #17803

    Nice to hear it. Thanks.

Tagged: 

You must be logged in to reply to this topic.