Hide Columns Based on User Role
Please note that this is now available as a plugin for easier installation. While you can use this document as a reference, the recommended method to add this functionality is through the plugin installation wizard. Learn more about plugins here.
This solution involves hiding columns based on the role of the logged-in user. This may be useful if some roles do not need to view certain columns on your table component.
Please note that this solution hides the value from the page so it can still be accessed if a user has some HTML knowledge. If the column must be secured from view for a specific role, we recommend creating separate secure pages per role to ensure that your data remains appropriately secure.
Step 1
Ensure your data table is set up to connect to the user roles.
Step 2
Add the CSS class of "role-hide" to the column you wish to hide.
Step 3
Get your component ID by hovering over the info icon.
Step 4
Add the following code to the JavaScript tab of your page.
TB.render('component_10', function(data) {
if (!"{loggedInUser.Role}".contains("Default Role")) {
$('.role-hide').hide();
}
});
Remember to change the component ID and the user role matching your app.
Original Community Post:
Hide Columns Based on User Role - Community Discussions / Tips and Tricks - Tadabase Community
We'd love to hear your feedback.