Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

Previously filtered user ID is no longer filtered Topic is solved

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
Paul
Posts: 112
Joined: Mon Aug 25, 2025 6:03 am
Has thanked: 27 times
Been thanked: 3 times

Previously filtered user ID is no longer filtered

Unread post by Paul »

The below code is placed in the Browse form.
When a non-admin user logs in, they see the User ID column that was previously successfully filtered out.
When printing, the user ID column is properly filtered out.

Code: Select all

if (!nuGlobalAccess()) {
	// Get hidden columns from hideBlankColumns
	const hiddenColumns = hideBlankColumns();

	// Add the manually specified column index
	var columnIndex = 0;

	// Combine both arrays and remove duplicates
	const columnsToExclude = [...new Set([columnIndex, ...hiddenColumns])];

	// Exclude all columns
	nuPrintExcludeColumns(columnsToExclude);
}

function hideBlankColumns() {
    const hiddenColumns = [];
    
    // Find the browse container element using its ID
    const browseDiv = document.getElementById('nuRECORD');
    if (!browseDiv) {
        console.error(`Browse div with ID "${'nuRECORD'}" not found.`);
        return hiddenColumns;
    }
    
    // Get all browse title divs (headers)
    const headers = browseDiv.querySelectorAll('.nuBrowseTitle');
    if (headers.length === 0) {
        console.error('No browse title headers found.');
        return hiddenColumns;
    }
    
    const colCount = headers.length;
    const isColumnBlank = new Array(colCount).fill(true);
    
    // Get all data cells (excluding empty rows)
    const dataCells = browseDiv.querySelectorAll('.nuCell[data-nu-column]');
    
    // Check each data cell to see if the column has content
    dataCells.forEach(cell => {
        const colIndex = parseInt(cell.getAttribute('data-nu-column'));
        const content = cell.textContent.trim();
        // Mark column as not blank if it has content
        if (content !== '' && colIndex >= 0) {
            isColumnBlank[colIndex] = false;
        }
    });
    
    // Hide blank columns using nuBuilder's built-in function
    for (let j = 0; j < colCount; j++) {
        if (isColumnBlank[j]) {
            nuSetBrowseColumnSize(j, 0);
            hiddenColumns.push(j);
        }
    }
    
    return hiddenColumns;
}
not-hidden.PNG
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4568
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 532 times
Contact:

Re: Previously filtered user ID is no longer filtered

Unread post by kev1n »

There's already a thread about this topic and you posted there the solution: viewtopic.php?p=31843#p31843

Code: Select all

if (!nuGlobalAccess()) {
    var columnIndex = 0;
    nuSetBrowseColumnSize(columnIndex, 0);
}
Paul
Posts: 112
Joined: Mon Aug 25, 2025 6:03 am
Has thanked: 27 times
Been thanked: 3 times

Re: Previously filtered user ID is no longer filtered

Unread post by Paul »

Ah, I accidently overwrote that previous code snippet. My mistake.
Post Reply