problem with draw

problem with draw

pmengopmengo Posts: 74Questions: 37Answers: 2

Cannot redefine record count on window[o].tbl.clear().draw();

If table have 3 records and i clear table with tbl.clear().draw() , number of records in datatables info dont reflect the correct number of records. It keeps the same info and should be 0.
I use server side processing.

Thanks

Answers

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

    Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.

    Information on how to create a test page, if you can't provide a link to your own page can be found here.

    Thanks,
    Allan

  • pmengopmengo Posts: 74Questions: 37Answers: 2
    edited July 2016

    http://www.quad-systems.pt/QUAD_PRS/#ajax/prs_articles.php

    Please clik a row A in first table to see the other tables filled. Click again to deselect the row and you will see empty table but with wrong info.

                                console.log(window[o].tbl.data().count());       *** correct info ex:3
                                window[o].tbl.clear().draw();
                                window[o].tbl.columns.adjust().draw();           *** dont update info !!!
                                console.log(window[o].tbl.data().count())        *** correct info ex: 0
    

    Processing is in server side mode...

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

    tbl.clear()

    However in your code:

    serverSide: true

    As the clear() documentation states:

    This method should not be used when serverSide is enabled. When server-side processing is enabled, the data should be deleted from the data store (i.e. an Ajax request to the server) and then draw() called. Deleting the client-side data will have no effect when server-side processing is enabled since the data would simply be restored on the next draw if the data is not removed from the server.

    You cannot use that method with serverSide. However, server-side processing is only useful for tables with tens of thousands of records. Are you really going to have that many for those two tables?

    Allan

  • pmengopmengo Posts: 74Questions: 37Answers: 2

    Yes ... i just want to redraw the table with no data, kind of reset it...
    The problem is that search() dont work either

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

    search() will make an Ajax request to the server if server-side processing is enabled. If that isn't working, you need to check your server-side processing implementation.

    To clear the table with server-side processing you would need to clear the server-side data source. You could possibly just use jQuery to remove the rows on the client-side, but any action that would redraw the table would cause them to be put back (since they are still present on the server-side).

    Allan

This discussion has been closed.