I'm following this guide: http://www.ahmed-samy.com/php-codeigniter-full-featrued-jquery-datatables-part-1/
Their script is:
<script type="text/javascript">
$(document).ready(function () {
var oTable = $('#big_table').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": '<?php echo base_url(); ?>index.php/subscriber/datatable',
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"iDisplayStart ": 20,
"oLanguage": {
"sProcessing": "<img src='<?php echo base_url(); ?>assets/images/ajax-loader_dark.gif'>"
},
"fnInitComplete": function () {
//oTable.fnAdjustColumnSizing();
},
'fnServerData': function (sSource, aoData, fnCallback) {
$.ajax
({
'dataType': 'json',
'type': 'POST',
'url': sSource,
'data': aoData,
'success': fnCallback
});
}
});
});
</script>
Here is my script:
<script>
$(document).ready(function() {
var oTable = $('#ManageForms').dataTable({
"bServerSide":true,
"bProcessing":true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
//"bFilter":true,
"sServerMethod": "POST",
"sAjaxSource": "{{base_url()}}admin/configurations/listForms_DT/",
"iDisplayLength": 2,
// "aLengthMenu": [[2, 25, 50, -1], [2, 25, 50, "All"]],
// "sEcho": 1,
/* "columns":[
{data:"FormName"},
{data:"FormPath"},
{data:"FormCIPath"},
{ "data": null,
"defaultContent": "<button>Edit</button>",
"targets": -1
}
],*/
'fnServerData' : function(sSource, aoData, fnCallback){
$.ajax ({
'dataType': 'json',
'type' : 'POST',
'url' : sSource,
'data' : aoData,
'success' : fnCallback
}); //end of ajax
}
});
} );
</script>
In tutorial they are not using columns and there table is working fine even with the search, but if I don't use columns which I have commented out, i get this error:
DataTables warning: table id=ManageForms - Requested unknown parameter '0' for row 0. For more information about this error, please see http://datatables.net/tn/4
If I do use the columns, datatables work fine but my search doesn't work. Why is it important for me to use columns but in tutorial they have not?
Where are you generating the table?
$this->table->generate();
Also, to search (filter), you need to append:
fnSetFilteringDelay(700); //delay amount