From f20b51b78ed5351ad3539a8e9bd428637472833b Mon Sep 17 00:00:00 2001 From: Sallu9007 Date: Sat, 10 May 2025 13:49:43 +0530 Subject: [PATCH] Feat: create toggle for columns --- .../pages/activities-attended/index.blade.php | 237 +++++++++++++++++- 1 file changed, 233 insertions(+), 4 deletions(-) diff --git a/resources/views/pages/activities-attended/index.blade.php b/resources/views/pages/activities-attended/index.blade.php index 59f251c..5e95a3f 100644 --- a/resources/views/pages/activities-attended/index.blade.php +++ b/resources/views/pages/activities-attended/index.blade.php @@ -7,10 +7,10 @@

- All Responses + All Responses

@if(auth()->user()->role->name === 'Admin') - @endif @@ -49,6 +49,97 @@
+ +
+ +
@@ -87,7 +178,7 @@ @@ -448,6 +539,144 @@ // Initialize the data table initAjaxRoute(dataRoute); + + // Function to toggle column visibility + function toggleColumnVisibility() { + $('.column-checkbox').each(function() { + const columnIndex = $(this).val(); + const isChecked = $(this).is(':checked'); + + // Show or hide the column based on checkbox state + table.column(columnIndex).visible(isChecked); + }); + + // Adjust table layout to prevent horizontal scrolling + table.columns.adjust().responsive.recalc(); + } + + // Attach change event listener to checkboxes + $('.column-checkbox').off('change').on('change', function() { + toggleColumnVisibility(); + }); + + // Ensure "Actions" column is always visible + $('#column-actions').prop('disabled', true); + + // Initial call to set column visibility + toggleColumnVisibility(); }); + + + + + @endsection \ No newline at end of file