sSearch in Datatables shows error when users try to find empty data

sSearch in Datatables shows error when users try to find empty data

blackpearl23blackpearl23 Posts: 1Questions: 1Answers: 0

I have a question. Why the datatables shows error "500 (Internal Server Error)" when users try to find a data by number turns out that the data isn't available. Here is my code for the Datatable:

var dataTable = $('#employee-grid').dataTable( {
"processing": true,
"serverSide": true,
info : false,
lengthChange: false,
scrollX: true,
scrollY: 400,
scrollCollapse: true,
lengthMenu: [[50], [50]],
order: [[ 9, "desc" ]],
fixedColumns : {
leftColumns: 3
},
language : {
"paginate": {
"previous": "Sebelumnya",
"next": "Berikutnya"
},
"search" : "Pencarian NPWP",
"zeroRecords": "Data Tidak Ada"
},
"columnDefs": [
{"targets": [0], "orderable": false},
{"targets": [1], "width": "150px"},
{"targets": [2], "width": "150px","searchable": true},
{"targets": [3], "width": "200px", "data": function(row, type, val, meta){
return row[3]+" "+row[4]+" "+row[5]+" "+row[6]+" "+row[7]+" "+row[8]+" "+row[9]+" "+row[10]+" "+row[11]+" "+row[12]+" "+row[13]+" "+row[14]+" "+row[15]+" "+row[16]+" "+row[17]+" "+row[18]+" "+row[19]+" "+row[20];
}, "orderable": false},
{"targets": [4], "width": "150px", "data": function(row, type, val, meta){return row[21]}},
{"targets": [5], "width": "250px", "data": function(row, type, val, meta){return row[22]}},
{"targets": [6], "width": "250px", "data": function(row, type, val, meta){return row[23]}},
{"targets": [7], "width": "250px", "data": function(row, type, val, meta){return row[24]}},
{"targets": [8], "width": "130px", "data": function(row, type, val, meta){return row[25]}},
{"targets": [9], "width": "90px", "data": function(row, type, val, meta){return row[26]}},
{"targets": [10], "width": "70px", "data": function(row, type, val, meta){return row[27]}},
{"targets": [11], "data": function(row, type, val, meta){return row[28]}},
{"targets": [12], "data": function(row, type, val, meta){return row[29]}},
{"targets": [13], "data": function(row, type, val, meta){return row[30]}},
{"targets": [14], "data": function(row, type, val, meta){return row[31]}},
{"targets": [15], "data": function(row, type, val, meta){return row[32]}},
{"targets": [16], "data": function(row, type, val, meta){return row[33]}},
{"targets": [17], "data": function(row, type, val, meta){return row[34]}},
{"targets": [18], "data": function(row, type, val, meta){return row[35]}},
{"targets": [19], "data": function(row, type, val, meta){return row[36]}},
{"targets": [20], "data": function(row, type, val, meta){return row[37]}},
{"targets": [21], "data": function(row, type, val, meta){return row[38]}},
{"targets": [22], "data": function(row, type, val, meta){return row[39]}},
{ className: "text-right", "targets": [22] },
{ className: "text-center", "targets": [0,2,11,12,13,14,15,16,17] }
],
"ajax":{
url :"{$this->createUrl('Ire/getWPCRMData')}", // json datasource
data :function(d){
d.parameter="{$apprHelper->serialize(
array(
'kdWilayahPilih'=>$kdWilayahPilih,
'tahunpajak'=>$thPilih,
'treatment'=>$treatment,
'jnswp'=>$jnswp,
'kelompokwp'=>$kelompokwp,
'category'=>$category,
'seksi'=>$seksi,
'atp5'=>$atp5,
'atp4'=>$atp4,
'atp3'=>$atp3,
'atp2'=>$atp2,
'atp1'=>$atp1,
'afiliasi'=>$afiliasi,
'stsspt'=>$stsspt,
'ista'=>$ista,
'ispps' => $ispps,
'iswpgrup'=>$iswpgrup,
'istbts'=>$istbts,
'isftz'=>$isftz,
'isimportir'=>$isimportir,
'isbeneficial'=>$isbeneficial,
'ishwi'=>$ishwi,
'istaxheaven'=>$istaxheaven,
'islawtax' => $islawtax,
'isrtlb' => $isrtlb,
'ispp23' => $ispp23,
'ispemeriksaan' => $ispemeriksaan,
'iswpsuspend' => $iswpsuspend,
'isne' => $isne,
'isneilap' => $isneilap,
'istdkspt' => $istdkspt,
'istdklaporilap' => $istdklaporilap
))}";
},
type: "post", // method , by default get
error: function(){ // error handling
$(".employee-grid-error").html("");
$("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="3" class="text-center">Tidak ada data</th></tr></tbody>');
$("#employee-grid_processing").css("display","none");

                }
            }
        } );

$('div.dataTables_filter label').append('<button type="button" class="btn default btn-sm" id="tombolCari">Cari</button>');
$("div.dataTables_filter input").unbind();

$('#tombolCari').click(function(e){
    dataTable.fnFilter($("div.dataTables_filter input").val());
});

$('#KPPEditable').editable(
{
    type: 'select',
    emptytext  : 'kosong',
    inputclass: 'form-control input-large',
    mode : 'inline',
    value : '{$kdWilayahPilih}',
    source: {$kppPilih_json}
});
$('#KPPEditable').on('save', function(e, params)
{
    EditableKPPSubmit(params.newValue);
});

$('#ThEditable').editable(
{
    type: 'select',
    //emptytext  : 'semua',
    mode : 'inline',
    value : '{$thPilih}',
    source: {$thpj_json}
});
$('#ThEditable').on('save', function(e, params)
{
    EditableTahunSubmit(params.newValue);
});

EOD;
Yii::app()->clientScript->registerScript('onReadyWpCRM',$onReady,CClientScript::POS_READY);

$onEnd=<<<EOD

var legendatribut = new Object();

legendatribut.legendOnClick = function()
{
    $('#legendonclick').modal('show');
}

function tanggapan(param)
{
    cklists = '';

    $('.selectrow').each(function()
    {
        cklists = cklists + $(this).val() + ';';
    });

    if (cklists == '')
        return;

    $('#CrmPenagihanFormOptModel_parameter').val(param);
    $('#CrmPenagihanFormOptModel_cklist').val(cklists);
    $('#cklistForm').submit();
}

function EditableKPPSubmit(value)
{
    $('#CrmIntegrasiModel_wilayah').val(value);
    $('#editableJenis').submit();
}

function EditableTahunSubmit(value)
{
    $('#CrmIntegrasiModel_tahunpajak').val(value);
    $('#editableJenis').submit();
}

EOD;
Yii::app()->clientScript->registerScript('onEndIdWP',$onEnd,CClientScript::POS_END);

From Datatables, it returns error : Undefined variable: data
Thanks

Answers

  • allanallan Posts: 63,180Questions: 1Answers: 10,411 Site admin

    A 500 error comes from the server. It could be literally anything on the server from a missing file to a DB error to a permissions error. You need to refer to the server's error log to see what is causing the error to occur.

    Allan

Sign In or Register to comment.