How to reset the files api collection?

How to reset the files api collection?

roi8877roi8877 Posts: 5Questions: 2Answers: 0

Hi,
I'm supporting .net code left by contractors and trying to figure out how all these things work by reading manual and forums alike.

I see from the api manual that the 'files' api (https://datatables.net/reference/api/files()) that it keeps track of all the files (and previous files) uploaded. Because the page uses the editor, and the editor does not get reloaded, any subsequent upload includes prior files. I wondering how can we reset the files collection? Reloading the page is not a viable option because there are filters the users have pre-selected and it would be lost when the page is reloaded...

Thanks

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,213Questions: 1Answers: 10,415 Site admin
    Answer ✓

    Hi,

    The object that contains the files information is accessible as $.fn.dataTable.Editor.files. It is an object that uses the table names as the key. Each parameter then contains an object with the file information.

    So you could do:

    $.fn.dataTable.Editor.files.myTable = {};
    

    to clear it out. It isn’t reactive though, anything depending on it would need to be redrawn / updated.

    Allan

  • roi8877roi8877 Posts: 5Questions: 2Answers: 0

    Great! Thanks. This works perfectly.

This discussion has been closed.