Page 1 of 1

Hide record checkboxes

Posted: 2025-06-05 03:26
by dlee
How can I hide the checkbox that are to the left of each record in tableview? They are confusing to my users.

TD

Re: Hide record checkboxes

Posted: 2025-06-05 04:42
by jsetzer
How can I hide the checkbox
Create file hooks/TABLENAME-tv.js, if not exists:

(1) Hide select-checkboxes in table view

Code: Select all

// file: hooks/TABLENAME-tv.js
jQuery(() => {
    jQuery('.record_selector,#select_all_records').hide()
});
This will hide the record-selector-checkboxes.

Note, an empty column will remain, which may also confuse users.

Removing checkboxes but keeping the first column is useful for example when having additional buttons in first column. Unless you need it, see alternative code below for hiding the whole column.

(2) Hide column, having select-checkboxes

Code: Select all

// file: hooks/TABLENAME-tv.js
jQuery(() => {
    jQuery('.record_selector,#select_all_records').closest('th,td').hide()
});
Please note that, when hiding the select checkboxes, you cannot multi-select records and therefore you cannot run batch-actions on selected records (like Delete selected records or any custom batch-action).

Re: Hide record checkboxes

Posted: 2025-06-05 06:27
by dlee
Thank you Jan ! One last question, the checkboxes and column appear just for a faction of a second then disappear whenever the page loads / reloads.
Is there a way to eliminate this? If not, your reply was a great help!

TD

Re: Hide record checkboxes

Posted: 2025-06-05 06:41
by jsetzer
You can try to hide the whole table using CSS, first, then .show() or .fadeIn() in Javascript after you have applied the checkbox-fix.

Hiding table using CSS could be done in hooks/header-extras.php, for example using display: none; on your table element. But I cannot guarantee this is flicker-free. Should be working - not tested.

Something like this:

Code: Select all

<!-- file: hooks/header-extras.php -->
<style>
    table[data-tablename="YOURTABLENAME"] {
        display: none;
    }
</style>

Code: Select all

// file: hooks/TABLENAME-tv.js
jQuery(() => {
    jQuery('.record_selector,#select_all_records').closest('th,td').hide()
    jQuery('table[data-tablename="YOURTABLENAME"]').show();
});


Note: If hiding in hooks/header-extras.php is too late and UI is still flickering, you may try in TABLENAME_header()-hook-function in hooks/TABLENAME.php. Not tested.

Re: Hide record checkboxes

Posted: 2025-06-06 02:43
by dlee
Jan your last post works perfectly! I always learn from your replies, thank you again!