Welcome to the nuBuilder Forums!

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

Filter a Browse Screen With a Checkbox

Questions related to using nuBuilder Forte.
Post Reply
giorgio58
Posts: 6
Joined: Wed Jan 01, 2020 6:43 pm

Filter a Browse Screen With a Checkbox

Unread post by giorgio58 »

In the new version, filters with check boxes no longer work on the browser screen. Has anything changed compared to the previous version?

No error is reported in nuDebug.

Thank you.
Screenshot_20200104_184448.png
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Filter a Browse Screen With a Checkbox

Unread post by kev1n »

How did you implement the filtering?
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Filter a Browse Screen With a Checkbox

Unread post by kev1n »

This code works for me:

Code: Select all

if (nuFormType() == 'browse') {
    custAddActionCheckbox("filterSomething", "Some Filter Text", "custSetCheckBoxFilter(this, '$id')", 5);
}

function custAddActionCheckbox(id, text, func, s) {
    var spaces = " ".repeat(s);
    var chkHtml =
        spaces + '<input type="checkbox" value="check" style="padding-left:100px;"  id="check' + id + '" onclick = "' +
        func.replace('$id', id) + '"/><label for="check' + id + '">' + nuTranslate(text) + '</label>&nbsp;';
    $('#nuActionHolder').append(chkHtml);
    $('#check' + id).attr('checked', nuGetProperty(id) === 'true');
}

function custSetCheckBoxFilter(chk, id) {
    nuSetProperty(id, $(chk).is(':checked').toString());
    nuSearchAction(1);
}
giorgio58
Posts: 6
Joined: Wed Jan 01, 2020 6:43 pm

Re: Filter a Browse Screen With a Checkbox

Unread post by giorgio58 »

Thanks for the reply,

before I used

Code: Select all

// inizio: elimina filtro operatore su browser
function nuAddActionCheckbox(i, v, f)
{
    var chk = '&nbsp;&nbsp;&nbsp;&nbsp;<label for = "check' + i + '">' + nuTranslate(v) + '</label><input type = "checkbox" value = "check" id = "check' + i + '" onclick = "' + f + '"/>&nbsp;';
    $('#nuActionHolder').append(chk);
}

function SetOperatoreFilter(chk)
{
    nuSetProperty('OperatoreFilter', $(chk).is(':checked'));
    nuSearchAction(1);
}

if (nuFormType() == 'browse')
{
    // valorizza nome utente
    nuSetProperty('nomeUtente', getUserName());

    var add = '&nbsp;&nbsp;<label for = "nomeUtente">' + nuTranslate("Operator Name") + '&nbsp;</label><input type = "text" id = "nomeUtente" value = "' + nuGetProperty('nomeUtente') + '" readonly/>';
    $('#nuActionHolder').append(add);
    $('label[for = nomeUtente]').css('position', 'relative');

    nuAddActionCheckbox("OperatoreFilter", "Exclude other users", "SetOperatoreFilter(this)");

    $('label[for = checkOperatoreFilter]').css('position', 'relative');
    $('#checkOperatoreFilter').attr('checked', nuGetProperty('OperatoreFilter'));
}
// fine: elimina filtro operatore su browser
and it worked in the previous version,
now I have modified the script as you suggested and it also works in the new version.
kev1n
nuBuilder Team
Posts: 4307
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 448 times
Contact:

Re: Filter a Browse Screen With a Checkbox

Unread post by kev1n »

Something must have changed recently.

Before it was possible to set a boolean value with nuSetProperty() and use that Hash Cookie in a browse sql:

Code: Select all

nuSetProperty('OperatoreFilter', $(chk).is(':checked'));
In the current version, the Hash cookie is empty, that's why I converted the boolean to a string with .toString() to make it work again:

Code: Select all

nuSetProperty(id, $(chk).is(':checked').toString());
Post Reply