DT_RowIndex not found but it exist
DT_RowIndex not found but it exist
function setDataTableByTgl(tglA = null, tglB = null, departemenId = null, group = true, seperate = false, pisah = true, barangId = null, kodeMerk = null){
setColumn(seperate)
$('.tableCustom1').DataTable().destroy();
var columns = [];
columns.push(
{ data: 'DT_RowIndex', name: 'DT_RowIndex', orderable: false, searchable: false },
{ data: 'cabang', name: 'cabang',
render: function (data, type, row){
return '<a class = view2 data-tgla="'+tglA+'" data-tglb="'+tglA+'" data-departemenId ="'+row.departemenId+'" data-tgl = "'+row.tgl1+'" data-seperate = true data-allKaryawan = true data-kodemerk="'+kodeMerk+'" data-barangid="'+barangId+'" >'+data+'</a>';
}
},
);
for(var count = 0; count < 31; count++){
columns.push(
{ data: count, name: count}
);
};
columns.push(
{ data: 'score', name: 'score' }
);
$('.tableCustom1').DataTable({
deferRender : true,
scrollX: "800px",
scrollY: "500px",
scrollCollapse: true,
paging: false,
processing: true,
serverSide: false,
fixedColumns: {
left: 0,
right: 1
},
order : [],
ajax: {
url: "{{ route('scoreboard.viewByTgl') }}",
type: "GET",
data: {
tglA: tglA,
tglB: tglB,
departemenId: departemenId,
group: group,
seperate: seperate,
pisah: pisah,
barangId: barangId,
kodeMerk: kodeMerk,
},
},
columns: columns
});
}
I got this following ajax which work because i set orderable: false, searchable: false
but i want it to be true for both so it can be sort but when i do that it will return error Uknown Column 'DT_RowIndex'
but in my json there is 'DT_RowIndex'
this only happen on transpose
query , this is the query :
$scoreboard = HistoryPenjualan::select(DB::raw('*'));
$count = [];
$scoreboard->from(function($query) use ( $hariSama, $tglA, $tglB, $departemenId, $kodeMerk, $barangId ){
$query ->selectRaw(DB::raw("DISTINCT DATE_FORMAT(`tgl`, '%Y-%m') as 'tgl1',`departemenId`, SUM(score) as totalScore"));
for ($j = 0; $j < 31; $j++){
$dateFormat = $hariSama[$j];
$query->selectRaw(DB::raw("(SUM(CASE WHEN tgl IN ($dateFormat) THEN score END) ) AS 'Hari$j' "));
};
if (!empty($kodeMerk)){
$query->whereRaw(DB::raw("EXISTS (SELECT * FROM `barang` where `history_penjualan`.`barangId` = `barang`.`id` and `kodeMerk` = '$kodeMerk')"));
}
if (!empty($barangId)){
$query->where('barangId', $barangId);
}
$query->whereBetween('tgl', [$tglA, $tglB])
->where('departemenId', $departemenId)
->groupBy('tgl1')
->from('history_penjualan');
});
for ($j = 1; $j < 32; $j++){
array_push($count, strval($j));
};
$scoreboard
->get();
It only happen to that query where i transpose stuff from row to column other query works just fine without orderable: false, searchable: false
, whats the cause of this ?
Does doing that query messed up datatables sorting and searching ?
Also iam using Yajrabox for the serverside on laravel
This question has an accepted answers - jump to answer
Answers
Can you show me the JSON response from the server please?
Allan
Already sent but it say the comment need to be approved first
this is one of the Response from JSON as you can see there is
DT_RowIndex
i got 41 other and all hasDT_RowIndex
with different numberThanks! That does look like it should be okay. I'm afraid I'm going to need more information. Are you able to give me a link to the page so I can debug it please? If that isn't possible, can you use the debugger to give me a trace please - click the Upload button and then let me know what the debug code is.
Allan
https://debug.datatables.net/asuvaz
but idk why its not found
For data security only I can view the uploads.
Interestingly there appears to be an issue displaying those results. I'll look into it and get back to you - although it might be tomorrow before I can do that now. Sorry.
Allan
I appriciate your help allan, i can wait. i like datatables because of the simplicity and customization you can do it help me alot + the forum is somewhat active too
I've managed to get the debugger showing me what I need to know again. Phew.
This is the SQL that the code is running:
What it doesn't like is
order by DT_RowIndex desc
. That doesn't exist in the database. I can't see in the above code where it would be defined if it isn't in the database - I can't even see where theselect
for it is - is that in the library code or something?Allan
Interesting, i use yajra own function to create
DT_RowIndex
using theaddIndexColumn()
,https://yajrabox.com/docs/laravel-datatables/10.0/index-column#main-content
the link for it. What i still dont understand is why only query like that where i transpose stuff that it doesnt recognize all"normal"
query is fineI honestly couldn't say - I'm not familiar with that code I'm afraid.
Allan
ahh okay no worry thanks for the help