I want add an index numbering from ajax in my table.
i have follow this documentation http://datatables.net/examples/api/counter_column.html and it give an error "requested unknown parameter '1' from the data source for row 0".
then i try search some solution in forum and do some googling. i make some modification from documentation like these.
my php:
this is link for debug result http://debug.datatables.net/ufazow
please help
i have follow this documentation http://datatables.net/examples/api/counter_column.html and it give an error "requested unknown parameter '1' from the data source for row 0".
then i try search some solution in forum and do some googling. i make some modification from documentation like these.
my php:
$this->load->library('datatables'); $this->datatables->from('lesson'); $this->datatables->select('lesson_name'); echo $this->datatables->generate();my javascript:
var get_jurusan = function (table, url) { var oTable = $('#'+table).dataTable({ "sPaginationType": "bs_normal", "bProcessing": true, "bServerSide": true, "sAjaxSource": url, "sServerMethod": "POST", "aoColumnDefs": [ { "bSortable": false, "aTargets": [ -1 ] } ], "aoColumns": [ { "sTitle": "Index", "fnDrawCallback": function ( oSettings ) { if ( oSettings.bSorted || oSettings.bFiltered ) { for ( var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++ ) { $('td:eq(0)', oSettings.aoData[ oSettings.aiDisplay[i] ].nTr ).html( i+1 ); } } } }, { "sTitle": "Lesson", "fnRender": function( oObj ) { return oObj.aData[0]} } ], "aLengthMenu": [ [1, 10, 15, 20, -1], [1, 10, 15, 20, "Semua"] ], "iDisplayLength": 10, }); wrapper(table); }; function wrapper(table){ $('#'+table+'_wrapper .dataTables_filter input').addClass("form-control input-sm").attr("placeholder", "Cari..."); $('#'+table+'_wrapper .dataTables_length select').addClass("m-wrap small"); $('#'+table+'_wrapper .dataTables_length select').select2(); }Ajax response:
{"sEcho":0,"iTotalRecords":3,"iTotalDisplayRecords":3,"aaData":[["Mathematic"],["Basic Algorithm"],["Java"]],"sColumns":"lesson_name"}but this make the lesson data show in both column like these http://oi40.tinypic.com/2lasb43.jpg.
this is link for debug result http://debug.datatables.net/ufazow
please help