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.
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.
Hide a specific Browse column except for globeadmin user
Hide a specific Browse column except for globeadmin user
How do I hide a specific column on the Browse form from all users except globeadmin?
-
- nuBuilder Team
- Posts: 4540
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 523 times
- Contact:
Re: Hide a specific Browse column except for globeadmin user
nuSetBrowseColumnSize(column, size) sets the width of a browse column (by index) to the given size.
If you want to "hide" a column, you can call:
This will set the width to 0 and hide the first column.
Example: Hide the 2nd column of not globeadmin:
(Add in form's Custom Code/Browse field)
If you want to "hide" a column, you can call:
Code: Select all
nuSetBrowseColumnSize(columnIndex, 0);
Example: Hide the 2nd column of not globeadmin:
Code: Select all
if (!nuGlobalAccess()) {
nuSetBrowseColumnSize(3,0);
}
Re: Hide a specific Browse column except for globeadmin user
Got an error using this:
Uncaught ReferenceError: columnIndex is not defined
Code: Select all
if (!nuGlobalAccess() !== 'globeadmin') {
nuSetBrowseColumnSize(columnIndex, 0);
}
Uncaught ReferenceError: columnIndex is not defined
-
- nuBuilder Team
- Posts: 4540
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 523 times
- Contact:
Re: Hide a specific Browse column except for globeadmin user
I updated the code above.
ChatGPT
I see what’s happening here. There are two issues in your code:
---
columnIndex is not defined
The error you’re getting is because columnIndex hasn’t been declared anywhere.
You need to pass an actual column index (0, 1, 2, …) or a variable that has been defined earlier.
Example:
-
Corrected version
ChatGPT
I see what’s happening here. There are two issues in your code:
---
columnIndex is not defined
The error you’re getting is because columnIndex hasn’t been declared anywhere.
You need to pass an actual column index (0, 1, 2, …) or a variable that has been defined earlier.
Example:
Code: Select all
var columnIndex = 2; // whichever column you want to hide
Code: Select all
if (!nuGlobalAccess()) {
var columnIndex = 2; // pick the column you want hidden
nuSetBrowseColumnSize(columnIndex, 0);
}
Re: Hide a specific Browse column except for globeadmin user
Error using this:
Uncaught TypeError: columnWidths.forEach is not a function
Code: Select all
//Hide column 1 if not globeadmin
if (nuGlobalAccess() !== 'globeadmin') {
var columnIndex = 1; // pick the column you want hidden
nuSetBrowseColumnSize(columnIndex, 0); //set column width to 0
}
-
- nuBuilder Team
- Posts: 4540
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 523 times
- Contact:
Re: Hide a specific Browse column except for globeadmin user
See nuGlobalAccess() usage above/wiki. Then, where exactly did you add the code?
Code: Select all
if (!nuGlobalAccess()) {
var columnIndex = 1; // pick the column you want hidden
nuSetBrowseColumnSize(columnIndex, 0); //set column width to 0
}
Re: Hide a specific Browse column except for globeadmin user
I added your code above in my form's Custom Code/Browse field. It does not work. All users still see column 1.
Column 1 is user1d
Column 1 is user1d
You do not have the required permissions to view the files attached to this post.
-
- nuBuilder Team
- Posts: 4540
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 76 times
- Been thanked: 523 times
- Contact:
Re: Hide a specific Browse column except for globeadmin user
The userId column appears to be the first column (index 0)
Re: Hide a specific Browse column except for globeadmin user
I changed the code to:
but still get the same result as in my last post - everyone still sees column 0.
Code: Select all
//Hide column 0 if not globeadmin
if (!nuGlobalAccess()) {
var columnIndex = 0; // pick the column you want hidden
nuSetBrowseColumnSize(columnIndex, 0); //set column width to 0
}