Retrieve:true reverts table to native html state

Retrieve:true reverts table to native html state

maximus1127maximus1127 Posts: 1Questions: 1Answers: 0
function createTable(){
$("#active-table").DataTable({
                pageLength: 50,
                retrieve: true
            })
}

I have this simple code in my page. Whenever the section gets reloaded via ajax, the table reverts back to its native html structure. how can I fix this? If I try to destroy the existing table with "destroy:true", the entire html gets deleted from the page source. This is odd because the documentation says this should NOT happen.

for the record, I'm calling my createTable() function from the "success" of my ajax call. I know it's getting hit because in my success method, I have it console logging "success", which does happen....the issue seems strictly related to the datatables "retrieve" parameter.

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Whenever the section gets reloaded via ajax, the table reverts back to its native html structure. how can I fix this?

    You would need to initialise the DataTable again - as DataTables isn't pulling the Ajax, you'll need to do that initialisation with the new data.

    This is odd because the documentation says this should NOT happen.

    Agreed, that shouldn't happen, so we would need to see that to understand the flow. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

Sign In or Register to comment.