52 lines
1.8 KiB
JavaScript

datatableKarbohidrat.bootstrapTable({
url: "/dashboard/datatable/karbohidrat",
showColumns: true,
showColumnsToggleAll: true,
showRefresh: true,
sortable: true,
search: true,
searchOnEnterKey: false,
searchHighlight: true,
pagination: true,
serverSide:true,
pageSize: 10,
pageList: [10, 20, 30],
cookie: true,
cookieIdTable: "datatableKlasifikasiMenu",
icons: {
refresh: "fas fa-sync-alt", // atau ganti ke icon lain
columns: "fas fa-th-large"
},
columns: [
{
title: "Action",
field: 'karbohidrat_id',
formatter: function(value, row) {
let buttons = ''
buttons += `
<button class="btn btn-sm btn-primary me-2" onclick="editKarbohidrat(this)" data-karbohidrat_id="${row.karbohidrat_id}" data-nama="${row?.nama_karbohidrat}">
<i class="fa-solid fa-pencil"></i>
</button>
`
buttons += `
<button class="btn btn-sm btn-danger me-2" onclick="deleteKarbohidrat(this)" data-karbohidrat_id="${row.karbohidrat_id}" data-nama="${row?.nama_karbohidrat}">
<i class="fa-solid fa-trash"></i>
</button>
`
return `
<div class="d-flex space-x">
${buttons}
</div>
`;
},
width: 120
},
{
title:"Nama Karbohidrat",
field:"nama_karbohidrat"
}
],
});