英文:
Datatables Laravel loop in ajax call using yajrabox
问题
// 如何使用 for 循环来添加直到第31天的列?或者我需要手动添加?另外,关于 `tgl: tgl`,我传递的 tgl 数据是作为数组,这样可以吗?
英文:
function setDataTableTgl(tgl = null, tglA = null, tglB = null, departemenId = null, group = true){
setColumn(group);
var tgl = {};
for (var i=1; i < 32; i++) {
tgl[i] = i;
};
$('.tableCustom3').DataTable().destroy();
$('.tableCustom3').DataTable({
processing: true,
serverSide: true,
bPaginate: false,
ajax: {
url: "{{ route('scoreboard.index') }}",
type: "GET",
data: {
tglA: tglA,
tglB: tglB,
departemenId: departemenId,
group: group,
tgl: tgl
}
},
columns: [
{ data: 'DT_RowIndex', name: 'DT_RowIndex' },
{ data: 'cabang', name: 'cabang' },
{ data: 'score', name: 'score' },
{ data: 'action', name: 'action' },
{ data: 'Day 1', name: 'Day 1' },
{ data: 'Day 2', name: 'Day 2' },
{ data: 'Day 3', name: 'Day 3' },
{ data: 'Day 4', name: 'Day 4' },
//i want this data to continue until Day 31
]
});
}
how to add the column that long with for ? or do i just have to manual it and also like to ask about the tgl: tgl
i pass the tgl data as array would it work ?
答案1
得分: 0
使用**JSON.stringify(array)**函数传递tgl数据。
ajax: {
url: "{{ route('scoreboard.index') }}",
type: "GET",
data: {
tglA: tglA,
tglB: tglB,
departemenId: departemenId,
group: group,
tgl: JSON.stringify(tgl)
}
}
英文:
-
pass tgl data using JSON.stringify(array) function.
ajax: { url: "{{ route('scoreboard.index') }}", type: "GET", data: { tglA: tglA, tglB: tglB, departemenId: departemenId, group: group, tgl: JSON.stringify(tgl) } },
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论