Created
August 31, 2023 06:12
-
-
Save hkkcngz/5d8bf7d052111f465c11a83bb1167b57 to your computer and use it in GitHub Desktop.
Bootstrap-table Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateBootstrapTable($id, $columns, $dataUrl, $extensions = []) { | |
$tableHtml = "<table id='$id' class='table table-striped'"; | |
// Temel ayarlar | |
$tableHtml .= ' data-id-field="id" data-unique-id="id" data-toolbar="#toolbar"'; | |
// Eklentileri ve özellikleri ekleyin | |
foreach($extensions as $key => $value) { | |
$tableHtml .= ' data-' . $key . '="' . $value . '"'; | |
} | |
// Tabloyu tamamlayın | |
$tableHtml .= "></table>"; | |
// Javascript kodu oluştur | |
$jsCode = "<script defer> | |
let dataForTable = {}; | |
document.addEventListener('DOMContentLoaded', async (event) => { | |
dataForTable = await fetchData('$dataUrl'); | |
$('#" . $id . "').bootstrapTable({ | |
data: dataForTable, | |
pagination: true, | |
search: true, | |
columns: " . json_encode($columns) . " | |
}); | |
}); | |
</script>"; | |
return $tableHtml . $jsCode; | |
} |
Author
hkkcngz
commented
Aug 31, 2023
Yeni Ekle
'id', 'title' => 'ID'],
['field' => 'username', 'title' => 'Kullanıcı Adı'],
['field' => 'rol', 'title' => 'Rol', 'formatter' => 'roleFormatter'],
['field' => 'aktivasyon', 'title' => 'Aktivasyon', 'formatter' => 'activationFormatter'],
['field' => 'eylem', 'title' => 'Eylem', 'align' => 'center', 'formatter' => 'actionsAddDeleteBtn', 'events' => 'window.actionsEvents']
];
echo generateBootstrapTable('tableUyeler', $columns, 'uyeler');
?>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment