see inserted data in Datatables

see inserted data in Datatables

Andreas S.Andreas S. Posts: 208Questions: 74Answers: 4

I need to insert data from an import file into the datatable. Sometimes it is only a data row but also several. When I inserted the data (Serverside) I see the inserted data only when I reload the whole page. How can I instruct Datatables to display the record immediately if it is in the visible range. The import always returns the record as JSON, but the datatable does not respond. I have read that it should go through AJAX load, however, I have no idea how. With the documentation I was also not smarter. How can I instruct datatables to display the record or reloading the part of the table without having to reload the whole page.

Andreas

This question has an accepted answers - jump to answer

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    The example for loading a JSON-formatted text file via Ajax is here:
    https://datatables.net/examples/data_sources/ajax.html

  • Andreas S.Andreas S. Posts: 208Questions: 74Answers: 4

    Sorry, I think you did not understand my Problem. I know about this example sites.
    I have already a datatable loaded on the webpage. I have a button to import some xml Data to the datatable that are already loaded. The Import to the Database works, but I see only the imported data in datatable if I reload the hole page.
    I want that the datatable show the new data without reload the whole page. I know I can do that with ajax, but I did not know how. The examples and the manual did not help me to solve my problem. I get for each imported Data a response in json format, that you see in the API editor manual. https://editor.datatables.net/manual/server

    Andreas

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    I want that the datatable show the new data without reload the whole page.

    ajax.reload() is the way to reload the DataTable's data (assuming that you are using ajax). The key here will be to call that only once your data has been fully uploaded and inserted into the database. You would need a callback from whatever you are using to upload the file in order to know when to call that method.

    Allan

This discussion has been closed.