Click here to Skip to main content
15,861,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
JavaScript
<script type="text/javascript" charset="utf-8">
//initialisation code
    $(document).ready(function() {
        $('#example').dataTable( {
			 "sPaginationType": "full_numbers",
			 
			
		
        } );
    } );
	
	var asInitVals = new Array();
	
    $(document).ready(function() {
 
        $("tfoot input").each( function (i) {
            asInitVals[i] = this.value;
        } );
		
		
        $("tfoot input").focus( function () {
            if ( this.className == "search_init" )
            {
                this.className = "";
                this.value = "";
            }
        } );
        $("tfoot input").blur( function (i) {
            if ( this.value == "" )
            {
                this.className = "search_init";
                this.value = asInitVals[$("tfoot input").index(this)];
            }
        } );
 
        var oTable = $('.exam').dataTable( {
            "oLanguage": {
                "sSearch": "Search all columns:"
            },
            "bStateSave": true,
            "fnInitComplete": function() {
                var oSettings = $('.exam').dataTable().fnSettings();
                for ( var i=0 ; i<oSettings.aoPreSearchCols.length ; i++ ){
                    if(oSettings.aoPreSearchCols[i].sSearch.length>0){
                        $("tfoot input")[i].value = oSettings.aoPreSearchCols[i].sSearch;
                        $("tfoot input")[i].className = "";
                    }
                }
            }
        } );
         
        $("tfoot input").keyup( function () {
            /* Filter on the column (the index) of this element */
            oTable.fnFilter( this.value, $("tfoot input").index(this) );
        } );
         
    } );
</script>

</head>

<body>

<table id="example" class = "exam" width="100%" border="1" cellpadding="0" cellspacing="0" class="pretty" align="center">


when I the table in browsers I see the error:
Data Tables warning (table id = 'example'): can not reinitialise Data Table.
To retrieve the data table object for this table, pass no arguments or see the
docs for bRetrieve and bDestroy


how to solve it??
Posted

1 solution

Based on one of the comments for the similar issue discussed here: http://datatables.net/forums/discussion/3307/error-message-cannot-reinitialise-datatable-when-table-is-blank/p1[^]

Try: Putting the script BELOW the table that is being populated - problem might be that the javascript is firing before the data is loaded.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900