Page 1 of 1

browse display checkboxes

Posted: Wed May 02, 2018 9:40 am
by Timo
A browse form shows 0 or 1 for TINYINT(1), BOOLEAN db fields. Checkboxes like ☑ / ☐ would look nicer. Is there an easy way to do this?

Re: browse display checkboxes

Posted: Thu May 03, 2018 1:50 am
by admin
Timo,

Try this - (place it in the Javascript of the Browse Form you want to change).

Code: Select all


    $("[data-nu-column='1']").each(function(index) {
        
        if($( this ).html() == '1'){
            $( this ).html('<input type="checkbox" checked>') 
        }else{
            
            if($( this ).html() != ''){
                $( this ).html('<input type="checkbox">') 
            }
            
        }

    });
    
Steven

Re: browse display checkboxes

Posted: Sat May 05, 2018 8:03 am
by toms
I made just a small improvement to this code so that checkboxes are not clickable but appear still enabled (not grayed out)

Code: Select all

    $("[data-nu-column='1']").each(function(index) {

        if ($(this).html() == '1') {
            $(this).html('<input type="checkbox"  checked onclick="this.checked=!this.checked;" >')
        } else {

            if ($(this).html() != '') {
                $(this).html('<input type="checkbox"  onclick="this.checked=!this.checked;">')
            }

        }

    });

Re: browse display checkboxes

Posted: Sun May 06, 2018 4:56 am
by admin
.