add overflow-x:auto to fix table when on mobile display

This commit is contained in:
cowrie committed 2026-11-14 20:53:28 +08:00
1 parent 6d882b78d1
commit 792d97712c
2 files changed
+136 -99

No files matched your search

+11 -1
View File
@@ -62,12 +62,20 @@
background: #f9f9f9;
border: 1px solid #ddd;
border-radius: 4px;
gap: 10px;
/* Adds space between the link and the button */
}
.file-item a {
color: #333;
text-decoration: none;
font-weight: 500;
/* These 3 lines fix the text overflow */
word-break: break-all;
overflow: hidden;
text-overflow: ellipsis;
/* Allow the link to shrink so the button doesn't get pushed out */
flex: 1;
}
.file-item a:hover {
@@ -78,6 +86,8 @@
.file-item button {
padding: 2px 8px;
font-size: 12px;
/* Prevent the button from shrinking or wrapping */
flex-shrink: 0;
}
</style>
</head>
@@ -130,7 +140,7 @@
<button class="btn btn-primary btn-xs" onclick="openAddModal()"><i class="fa fa-plus"></i>
Tambah Penelitian</button>
</header>
<div class="panel-body">
<div class="panel-body" style="overflow-x: auto;">
<table id="tablePenelitian" class="table table-striped table-bordered dt-responsive nowrap"
style="width:100%">
<thead>
+125 -98
View File
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
@@ -20,113 +21,132 @@
<!-- Sweet Alert -->
<link rel="stylesheet" href="assets/plugin/sweet-alert/sweetalert.css">
<!-- Color Picker -->
<link rel="stylesheet" href="assets/color-switcher/color-switcher.min.css">
<!-- Data Tables -->
<link rel="stylesheet" href="assets/plugin/datatables/media/css/dataTables.bootstrap.min.css">
<link rel="stylesheet" href="assets/plugin/datatables/extensions/Responsive/css/responsive.bootstrap.min.css">
<style>
/* Custom style for file list inside table */
.file-list { list-style: none; padding: 0; margin: 0; }
.file-list li { margin-bottom: 3px; }
.file-list a { color: #007bff; text-decoration: none; }
.file-list a:hover { text-decoration: underline; }
.file-list {
list-style: none;
padding: 0;
margin: 0;
}
.file-list li {
margin-bottom: 3px;
}
.file-list a {
color: #007bff;
text-decoration: none;
}
.file-list a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="main-menu">
<header class="header">
<a href="index.html" class="logo">Tugas RPL</a>
<button type="button" class="button-close fa fa-times js__menu_close"></button>
<div class="user">
<a href="#" class="avatar"><img src="assets/images/person.png" alt=""><span class="status online"></span></a>
<h5 class="name"><a href="profile.html">Tamu</a></h5>
<h5 class="position">Tamu</h5>
<div class="main-menu">
<header class="header">
<a href="index.html" class="logo">Tugas RPL</a>
<button type="button" class="button-close fa fa-times js__menu_close"></button>
<div class="user">
<a href="#" class="avatar"><img src="assets/images/person.png" alt=""><span
class="status online"></span></a>
<h5 class="name"><a href="profile.html">Tamu</a></h5>
<h5 class="position">Tamu</h5>
</div>
<!-- /.user -->
</header>
<!-- /.header -->
<div class="content">
<div class="navigation">
<h5 class="title">Navigasi</h5>
<!-- /.title -->
<ul class="menu js__accordion">
<li>
<a class="waves-effect" href="login.html"><i
class="menu-icon fa fa-sign-in"></i><span>Login</span></a>
</li>
</ul>
</div>
<!-- /.navigation -->
</div>
<!-- /.user -->
</header>
<!-- /.header -->
<div class="content">
<!-- /.content -->
</div>
<!-- /.main-menu -->
<div class="navigation">
<h5 class="title">Navigasi</h5>
<!-- /.title -->
<ul class="menu js__accordion">
<li>
<a class="waves-effect" href="login.html"><i class="menu-icon fa fa-sign-in"></i><span>Login</span></a>
</li>
</ul>
<div class="fixed-navbar">
<div class="pull-left">
<button type="button"
class="menu-mobile-button glyphicon glyphicon-menu-hamburger js__menu_mobile"></button>
<h1 class="page-title">Halaman Utama</h1>
<!-- /.page-title -->
</div>
<!-- /.navigation -->
<!-- /.pull-left -->
<div class="pull-right">
<div class="ico-item fa fa-arrows-alt js__full_screen"></div>
<a href="login.html" class="ico-item fa fa-sign-in"></a>
</div>
<!-- /.pull-right -->
</div>
<!-- /.content -->
</div>
<!-- /.main-menu -->
<div class="fixed-navbar">
<div class="pull-left">
<button type="button" class="menu-mobile-button glyphicon glyphicon-menu-hamburger js__menu_mobile"></button>
<h1 class="page-title">Halaman Utama</h1>
<!-- /.page-title -->
</div>
<!-- /.pull-left -->
<div class="pull-right">
<div class="ico-item fa fa-arrows-alt js__full_screen"></div>
<a href="login.html" class="ico-item fa fa-sign-in"></a>
</div>
<!-- /.pull-right -->
</div>
<!-- /.fixed-navbar -->
<!-- /.fixed-navbar -->
<div id="wrapper">
<div class="main-content">
<!-- ================= NEW CONTENT START ================= -->
<div class="row small-spacing">
<div class="col-md-12">
<div class="box-content">
<header class="panel-heading" style="display: flex; justify-content: space-between; align-items: center;">
<h4 class="box-title" style="margin: 0;">Daftar Penelitian Dosen</h4>
</header>
<div class="panel-body">
<!-- DataTables will automatically add a search box here -->
<table id="tabelPenelitian" class="table table-striped table-bordered dt-responsive nowrap" width="100%">
<thead>
<tr>
<th>No</th>
<th>Nama Dosen</th>
<th>Judul Penelitian</th>
<th>Tahun</th>
<th>Status</th>
<th>Hasil Publikasi (PDF)</th>
</tr>
</thead>
<tbody>
<!-- Data will be populated via AJAX -->
</tbody>
</table>
<div id="wrapper">
<div class="main-content">
<!-- ================= NEW CONTENT START ================= -->
<div class="row small-spacing">
<div class="col-md-12">
<div class="box-content">
<header class="panel-heading"
style="display: flex; justify-content: space-between; align-items: center;">
<h4 class="box-title" style="margin: 0;">Daftar Penelitian Dosen</h4>
</header>
<div class="panel-body" style="overflow-x: auto;">
<!-- DataTables will automatically add a search box here -->
<table id="tabelPenelitian" class="table table-striped table-bordered dt-responsive nowrap"
width="100%">
<thead>
<tr>
<th>No</th>
<th>Nama Dosen</th>
<th>Judul Penelitian</th>
<th>Tahun</th>
<th>Status</th>
<th>Hasil Publikasi (PDF)</th>
</tr>
</thead>
<tbody>
<!-- Data will be populated via AJAX -->
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- ================= NEW CONTENT END ================= -->
<footer class="footer">
<ul class="list-inline">
<li>2026 © Tugas RPL.</li>
</ul>
</footer>
</div>
<!-- ================= NEW CONTENT END ================= -->
<!-- /.main-content -->
</div><!--/#wrapper -->
<footer class="footer">
<ul class="list-inline">
<li>2026 © Tugas RPL.</li>
</ul>
</footer>
</div>
<!-- /.main-content -->
</div><!--/#wrapper -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="assets/scripts/jquery.min.js"></script>
<script src="assets/scripts/modernizr.min.js"></script>
@@ -142,46 +162,45 @@
<script src="assets/plugin/datatables/media/js/dataTables.bootstrap.min.js"></script>
<script src="assets/plugin/datatables/extensions/Responsive/js/dataTables.responsive.min.js"></script>
<script src="assets/plugin/datatables/extensions/Responsive/js/responsive.bootstrap.min.js"></script>
<script src="assets/scripts/main.min.js"></script>
<script src="assets/color-switcher/color-switcher.min.js"></script>
<!-- ================= CUSTOM SCRIPT FOR INDEX ================= -->
<script>
$(document).ready(function() {
$('#tabelPenelitian').DataTable({
$(document).ready(function () {
var table = $('#tabelPenelitian').DataTable({
"ajax": {
"url": "/api/penelitian", // Fetch data from backend
"dataSrc": ""
},
"columns": [
{
// Auto increment number based on pagination
{
// Give it a class so we can easily find it later
"data": null,
"className": "row-number",
"render": function (data, type, row, meta) {
// Initial render (will be updated by the event listener below)
return meta.row + meta.settings._iDisplayStart + 1;
}
},
{ "data": "dosen_name" },
{ "data": "judul_penelitian" },
{ "data": "tahun_penelitian" },
{
{
"data": "status_penelitian",
"render": function(data) {
// Added colored badges just like in dosen.html
"render": function (data) {
let badge = data === 'Berjalan' ? 'label-warning' : 'label-success';
return `<span class="label ${badge}">${data}</span>`;
}
},
{
{
"data": "hasil_publikasi",
"render": function(data, type, row) {
// Parse the JSON array of filenames safely
"render": function (data, type, row) {
if (data) {
try {
// Handle both string JSON and already parsed Arrays from the DB
const files = typeof data === 'string' ? JSON.parse(data) : data;
if (Array.isArray(files) && files.length > 0) {
let html = '<ul class="file-list">';
files.forEach(f => {
@@ -198,9 +217,17 @@
}
}
],
"order": [[ 3, "desc" ]] // Sort by Year (descending) by default
"order": [[3, "asc"]] // Sort by Year (ascending) by default
});
// THIS IS THE FIX: Update the "No" column every time the table is drawn (sorted, searched, paged)
table.on('order.dt search.dt draw.dt', function () {
table.column(0, { search: 'applied', order: 'applied' }).nodes().each(function (cell, i) {
cell.innerHTML = i + 1;
});
}).draw();
});
</script>
</body>
</html>