If there are no entries in the subform - to hide the subform
Posted: Fri May 22, 2020 4:15 pm
If there are no entries in the subform - how to hide the subform ?
https://forums.nubuilder.cloud/
Code: Select all
var subformId = 'accform'; // <--- replace with your subform object ID
if (nuSubformObject(subformId).rows.length < 2) {
nuHide(subformId);
}
Thanks, it works for me.kev1n wrote:Please let me know if the code works for you.
Code: Select all
function hideEmptySubforms() {
nuSERVERRESPONSE.objects.map(item => {
if (item.type == 'subform') {
if (nuSubformObject(item.id).rows.length == 1) {
nuHide(item.id);
}
}
})
}
Unfortunately this doesn't work - nothing happens.kev1n wrote:Call this function hideEmptySubforms() to hide all empty subforms
Code: Select all
function hideEmptySubforms() { nuSERVERRESPONSE.objects.map(item => { if (item.type == 'subform') { if (nuSubformObject(item.id).rows.length == 1) { nuHide(item.id); } } }) }
First I tried it without specifying a function, then I hung it up on the button of the main form through onclick.kev1n wrote:How did you call the function and where?
Code: Select all
hideEmptySubforms();
kev1n wrote:You need to call the function somewhere
Code: Select all
hideEmptySubforms();