Added RowClass option to toggle showing each dataset row as individual col-xx-xx Bootstrap classes (for datasets that return few results but large number of columns)

This commit is contained in:
Conner Harkness 2025-09-03 14:24:19 -06:00
parent 54d145e30d
commit 50bf5bead3

View File

@ -214,7 +214,7 @@
<?php if ($varRows !== null && count($varRows) > 0): ?>
<a class="nav-item btn btn-outline-light me-2" onclick="fnShowPage('#page-output');"><i class="fa fa-fw fa-table"></i> <span class="d-none d-lg-inline">Results</span></a>
<a class="nav-item btn btn-outline-light me-2" onclick="fnExport();"><i class="fa fa-fw fa-download"></i> <span class="d-none d-lg-inline">.csv</span></a>
<a class="nav-item btn btn-outline-light me-2" onclick="fnExport();" id="export-csv-button"><i class="fa fa-fw fa-download"></i> <span class="d-none d-lg-inline">.csv</span></a>
<?php endif; ?>
</div>
</div>
@ -301,24 +301,24 @@
if (strlen($varInputs[5][$i]) > 0)
$strInputDefaultValue = $varInputs[5][$i];
$varOptions = [];
$varInputOptions = [];
if (strtolower($varInputs[4][$i]) == "options")
{
$strOptionsList = $varInputs[5][$i];
$varOptions = explode(",", $strOptionsList);
$varInputOptions = explode(",", $strOptionsList);
}
?>
<div class="mb-3">
<label><?= $strInputName; ?> <code><?= $strInputType; ?></code></label>
<?php if (count($varOptions) > 0): ?>
<?php if (count($varInputOptions) > 0): ?>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-at"></i></span>
<select class="form-select" name="<?= $strInputName; ?>">
<?php foreach ($varOptions as $o): ?>
<?php foreach ($varInputOptions as $o): ?>
<?php
$strLabel = $o;
$strValue = $o;
@ -413,6 +413,11 @@
foreach ($varRow1 as $k => $v)
$varColumns[] = $k;
$strRowClass = null;
if (array_key_exists("rowclass", $varOptions))
if (preg_match("/^col\-/i", $varOptions["rowclass"]))
$strRowClass = $varOptions["rowclass"];
?>
<div class="d-none d-print-block">
@ -438,6 +443,55 @@
</div>
</div>
<?php if ($strRowClass !== null): ?>
<div class="container-fluid">
<div class="row my-3">
<?php foreach ($varRows as $r): ?>
<div class="<?= $strRowClass; ?>">
<table class="table table-sm table-striped table-bordered">
<thead>
<tr>
<th class="bg-black text-white"><?= $varColumns[0]; ?></th>
<th class="bg-black text-white"><?= $r[$varColumns[0]]; ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($varColumns as $col): ?>
<?php
// Hide columns that begin with underscore:
if ($col[0] == "_")
continue;
?>
<tr>
<td><?= $col; ?></td>
<td><?= $r[$col]; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endforeach; ?>
</div>
</div>
<script>
$(function() {
$("#export-csv-button")
.first()
.addClass("d-none");
});
</script>
<?php else: ?>
<div class="table-responsive">
<table class="table table-sm table-striped table-bordered w-100" id="table">
<thead class="sticky-top">
@ -495,6 +549,7 @@
</table>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
<script>