How to destroy the table once it click

How to destroy the table once it click

nitishshadcvknitishshadcvk Posts: 4Questions: 2Answers: 0

Hi All,

As I am totally new in Jquery table,my requirement is that at the time of load the page I am to see the jquery table along with records,but when i select any picklist value the jquery table disappers and looks into simple format.

var oTable;
var currentNumberDisplayed = 5;

    $(document).ready(function() {
        $('#load').click( function () {
            var oSettings = oTable.fnSettings();
            console.log(oSettings);
            currentNumberDisplayed += 5;
            oSettings._iDisplayLength = currentNumberDisplayed;
            oTable.fnDraw();
            console.log(oSettings);
            destroy: true
        });

        oTable = $('[id$=testTable]').dataTable({
            "iDisplayLength": 5
        });
        oTable = $('[id$=testTable1]').dataTable({
            "iDisplayLength": 5
        });
    });

Answers

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

    Hi @nitishshadcvk ,

    You can use destroy() to remove the table.

    Cheers,

    Colin

  • nitishshadcvknitishshadcvk Posts: 4Questions: 2Answers: 0
    edited March 2019

    @Colin
    I m trying but not achive.

    Could you please help me out!!

    Please see the below code:

  • nitishshadcvknitishshadcvk Posts: 4Questions: 2Answers: 0
        var oTable;
        var currentNumberDisplayed = 5;
    
        var oTable1;
    
        $(document).ready(function() {
            $('#load').click( function () {
                var oSettings = oTable.fnSettings();
                console.log(oSettings);
                currentNumberDisplayed += 5;
                oSettings._iDisplayLength = currentNumberDisplayed;
                oTable.fnDraw();
                console.log(oSettings);
    
            });
    
            oTable = $('[id$=testTable]').dataTable({
                "iDisplayLength": 5
                //    "paging":false
            });
            oTable = $('[id$=testTable1]').dataTable({
                "iDisplayLength": 5
            });
    
            $('#load').click( function () {
                var oSettings = oTable.fnSettings();
                console.log(oSettings);
                currentNumberDisplayed += 5;
                oSettings._iDisplayLength = currentNumberDisplayed;
                oTable.fnDestroy();
    
    
            });
    
  • kthorngrenkthorngren Posts: 20,277Questions: 26Answers: 4,766

    Are you getting errors in your browser's console? My guess is you are running into the error discussed in this FAQ:
    https://datatables.net/faqs/index#api

    Kevin

This discussion has been closed.