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
+65 -28

No files matched your search

+11 -1
View File
@@ -62,12 +62,20 @@
background: #f9f9f9; background: #f9f9f9;
border: 1px solid #ddd; border: 1px solid #ddd;
border-radius: 4px; border-radius: 4px;
gap: 10px;
/* Adds space between the link and the button */
} }
.file-item a { .file-item a {
color: #333; color: #333;
text-decoration: none; text-decoration: none;
font-weight: 500; 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 { .file-item a:hover {
@@ -78,6 +86,8 @@
.file-item button { .file-item button {
padding: 2px 8px; padding: 2px 8px;
font-size: 12px; font-size: 12px;
/* Prevent the button from shrinking or wrapping */
flex-shrink: 0;
} }
</style> </style>
</head> </head>
@@ -130,7 +140,7 @@
<button class="btn btn-primary btn-xs" onclick="openAddModal()"><i class="fa fa-plus"></i> <button class="btn btn-primary btn-xs" onclick="openAddModal()"><i class="fa fa-plus"></i>
Tambah Penelitian</button> Tambah Penelitian</button>
</header> </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" <table id="tablePenelitian" class="table table-striped table-bordered dt-responsive nowrap"
style="width:100%"> style="width:100%">
<thead> <thead>
+54 -27
View File
@@ -1,5 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
@@ -30,20 +31,35 @@
<style> <style>
/* Custom style for file list inside table */ /* Custom style for file list inside table */
.file-list { list-style: none; padding: 0; margin: 0; } .file-list {
.file-list li { margin-bottom: 3px; } list-style: none;
.file-list a { color: #007bff; text-decoration: none; } padding: 0;
.file-list a:hover { text-decoration: underline; } margin: 0;
}
.file-list li {
margin-bottom: 3px;
}
.file-list a {
color: #007bff;
text-decoration: none;
}
.file-list a:hover {
text-decoration: underline;
}
</style> </style>
</head> </head>
<body> <body>
<div class="main-menu"> <div class="main-menu">
<header class="header"> <header class="header">
<a href="index.html" class="logo">Tugas RPL</a> <a href="index.html" class="logo">Tugas RPL</a>
<button type="button" class="button-close fa fa-times js__menu_close"></button> <button type="button" class="button-close fa fa-times js__menu_close"></button>
<div class="user"> <div class="user">
<a href="#" class="avatar"><img src="assets/images/person.png" alt=""><span class="status online"></span></a> <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="name"><a href="profile.html">Tamu</a></h5>
<h5 class="position">Tamu</h5> <h5 class="position">Tamu</h5>
</div> </div>
@@ -57,7 +73,8 @@
<!-- /.title --> <!-- /.title -->
<ul class="menu js__accordion"> <ul class="menu js__accordion">
<li> <li>
<a class="waves-effect" href="login.html"><i class="menu-icon fa fa-sign-in"></i><span>Login</span></a> <a class="waves-effect" href="login.html"><i
class="menu-icon fa fa-sign-in"></i><span>Login</span></a>
</li> </li>
</ul> </ul>
@@ -65,12 +82,13 @@
<!-- /.navigation --> <!-- /.navigation -->
</div> </div>
<!-- /.content --> <!-- /.content -->
</div> </div>
<!-- /.main-menu --> <!-- /.main-menu -->
<div class="fixed-navbar"> <div class="fixed-navbar">
<div class="pull-left"> <div class="pull-left">
<button type="button" class="menu-mobile-button glyphicon glyphicon-menu-hamburger js__menu_mobile"></button> <button type="button"
class="menu-mobile-button glyphicon glyphicon-menu-hamburger js__menu_mobile"></button>
<h1 class="page-title">Halaman Utama</h1> <h1 class="page-title">Halaman Utama</h1>
<!-- /.page-title --> <!-- /.page-title -->
</div> </div>
@@ -81,23 +99,25 @@
<a href="login.html" class="ico-item fa fa-sign-in"></a> <a href="login.html" class="ico-item fa fa-sign-in"></a>
</div> </div>
<!-- /.pull-right --> <!-- /.pull-right -->
</div> </div>
<!-- /.fixed-navbar --> <!-- /.fixed-navbar -->
<div id="wrapper"> <div id="wrapper">
<div class="main-content"> <div class="main-content">
<!-- ================= NEW CONTENT START ================= --> <!-- ================= NEW CONTENT START ================= -->
<div class="row small-spacing"> <div class="row small-spacing">
<div class="col-md-12"> <div class="col-md-12">
<div class="box-content"> <div class="box-content">
<header class="panel-heading" style="display: flex; justify-content: space-between; align-items: center;"> <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> <h4 class="box-title" style="margin: 0;">Daftar Penelitian Dosen</h4>
</header> </header>
<div class="panel-body"> <div class="panel-body" style="overflow-x: auto;">
<!-- DataTables will automatically add a search box here --> <!-- DataTables will automatically add a search box here -->
<table id="tabelPenelitian" class="table table-striped table-bordered dt-responsive nowrap" width="100%"> <table id="tabelPenelitian" class="table table-striped table-bordered dt-responsive nowrap"
width="100%">
<thead> <thead>
<tr> <tr>
<th>No</th> <th>No</th>
@@ -125,7 +145,7 @@
</footer> </footer>
</div> </div>
<!-- /.main-content --> <!-- /.main-content -->
</div><!--/#wrapper --> </div><!--/#wrapper -->
<!-- Placed at the end of the document so the pages load faster --> <!-- Placed at the end of the document so the pages load faster -->
<script src="assets/scripts/jquery.min.js"></script> <script src="assets/scripts/jquery.min.js"></script>
@@ -148,17 +168,19 @@
<!-- ================= CUSTOM SCRIPT FOR INDEX ================= --> <!-- ================= CUSTOM SCRIPT FOR INDEX ================= -->
<script> <script>
$(document).ready(function() { $(document).ready(function () {
$('#tabelPenelitian').DataTable({ var table = $('#tabelPenelitian').DataTable({
"ajax": { "ajax": {
"url": "/api/penelitian", // Fetch data from backend "url": "/api/penelitian", // Fetch data from backend
"dataSrc": "" "dataSrc": ""
}, },
"columns": [ "columns": [
{ {
// Auto increment number based on pagination // Give it a class so we can easily find it later
"data": null, "data": null,
"className": "row-number",
"render": function (data, type, row, meta) { "render": function (data, type, row, meta) {
// Initial render (will be updated by the event listener below)
return meta.row + meta.settings._iDisplayStart + 1; return meta.row + meta.settings._iDisplayStart + 1;
} }
}, },
@@ -167,19 +189,16 @@
{ "data": "tahun_penelitian" }, { "data": "tahun_penelitian" },
{ {
"data": "status_penelitian", "data": "status_penelitian",
"render": function(data) { "render": function (data) {
// Added colored badges just like in dosen.html
let badge = data === 'Berjalan' ? 'label-warning' : 'label-success'; let badge = data === 'Berjalan' ? 'label-warning' : 'label-success';
return `<span class="label ${badge}">${data}</span>`; return `<span class="label ${badge}">${data}</span>`;
} }
}, },
{ {
"data": "hasil_publikasi", "data": "hasil_publikasi",
"render": function(data, type, row) { "render": function (data, type, row) {
// Parse the JSON array of filenames safely
if (data) { if (data) {
try { try {
// Handle both string JSON and already parsed Arrays from the DB
const files = typeof data === 'string' ? JSON.parse(data) : data; const files = typeof data === 'string' ? JSON.parse(data) : data;
if (Array.isArray(files) && files.length > 0) { if (Array.isArray(files) && files.length > 0) {
@@ -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> </script>
</body> </body>
</html> </html>