i have a problem initializing the data table i have tried many options in the forums

i have a problem initializing the data table i have tried many options in the forums

himaantheonehimaantheone Posts: 2Questions: 1Answers: 0
edited June 2016 in Free community support

basically i have a search engine that sends a searchterm and retrieve results so i am getting that table cannot be reinitialised error following is my code-

        var search = $("#grid-selection");
 search.find(".dataTable").dataTable().fnDestroy();

        var Searchterm = $('#Searchterm').val();
        

        
        var table= $("#grid-selection").DataTable({
            "ajax": {
                "url": "Prime/Time/Search",
                "type": "POST",
                "data": { Searchterm: Searchterm },

                "datatype": "json"
            },
            
            "scrollY": 350,
            "scrollX": true,
            "columns" : [
                    { "data": "id", "autoWidth": true },
                    { "data": "brieftitle", "autoWidth": true },
                   
                   
            ]
        });  

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 61,805Questions: 1Answers: 10,119 Site admin

    Change:

    search.find(".dataTable").dataTable().fnDestroy();

    to be:

    search.dataTable().fnDestroy();
    

    Otherwise it is looking for tables inside the table you want!

    Allan

This discussion has been closed.