Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Checkbox in Browse View Topic is solved

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
justme636
Posts: 21
Joined: Wed Dec 14, 2022 10:56 am
Has thanked: 6 times
Been thanked: 4 times

Checkbox in Browse View

Unread post by justme636 »

Hello there!

In one Browse view, I created an extra column with a check in Javascript/jQuery. All in all, it works fine, but there is a problem with ticking the checkbox; sometimes, it needs two or three quick clicks to get it activated, usually the same with deactivating the box. I got the impression, the checkbox sind not implemented properly and some elements/functions are in conflict with the checkbox.

Here are the codes from the Custom Code field:

Code: Select all

if (nuFormType() == 'browse') {
addCheckbox();
}

function nuSelectBrowse(element) {
    const col = $(element.target).attr('data-nu-column');
    if (col !== '0' && typeof col !== "undefined") {
        const primaryKey = $(element).attr('data-nu-primary-key');
        nuForm(nuFormId(), primaryKey, '', '', '1');
    } else {
        return false;
    }
}

function addCheckbox() {
$("[data-nu-column='0']").each(function(index) {
    let pk = $(this).attr('data-nu-primary-key');
    if (typeof pk !== "undefined") {
        let checked = $(this).html() == '1' ? 'checked="checked"': '';
        $(this).html('<input type="checkbox" ' + checked + ' id="' + pk + '" name="mycheckbox[]">')}
});
}
Does anyone have an idea why the checkbox can't get (de-)activated with a single click?
Last edited by justme636 on Sun Jun 23, 2024 11:27 am, edited 1 time in total.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Checkbox in Browse View

Unread post by kev1n »

Hi,

Change

Code: Select all

return false;
to

Code: Select all

return;
in you nuSelectBrowse()
justme636
Posts: 21
Joined: Wed Dec 14, 2022 10:56 am
Has thanked: 6 times
Been thanked: 4 times

Re: Checkbox in Browse View

Unread post by justme636 »

Hi kev1n,

thank you, it works! Sometimes it is just a word too much...

Anyway, I use these functions to select rows in the browse view by clicking the checkbox and run a function for all selected rows. I think the principle of "select rows and do something with selected rows" is widely used. At least I know and appreciate it in several applications. Have you considered to implement it as a native function in nuBuilder?
justme636
Posts: 21
Joined: Wed Dec 14, 2022 10:56 am
Has thanked: 6 times
Been thanked: 4 times

Re: Checkbox in Browse View

Unread post by justme636 »

I opened another discussion about this in the Ideas & Suggestions subforum: viewtopic.php?t=12312
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Checkbox in Browse View

Unread post by kev1n »

Thank you for your suggestion. This will be evaluated, but we must consider that needs could vary and other requirements must be taken into account, such as "select all," "unselect all," dealing with multiple browse pages, running a function on a button click or when selected, etc.
Post Reply