Page 1 of 1

Filter a Browse Screen With a Checkbox

Posted: Sat Jan 04, 2020 6:46 pm
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

Re: Filter a Browse Screen With a Checkbox

Posted: Sat Jan 04, 2020 8:06 pm
by kev1n
How did you implement the filtering?

Re: Filter a Browse Screen With a Checkbox

Posted: Sat Jan 04, 2020 9:02 pm
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);
}

Re: Filter a Browse Screen With a Checkbox

Posted: Sun Jan 05, 2020 10:14 am
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.

Re: Filter a Browse Screen With a Checkbox

Posted: Mon Jan 06, 2020 8:54 am
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());