Show columns based on the Users 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 is a way to customize a table with different views based on the logged-in user's role. Follow the steps below for this great customization.
Please note that this solution simply 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 certain role, we recommend creating separate secure pages per role to ensure that your data remains appropriately secure.
Step 1
Make sure you attach a specified role to each user.
Step 2
Add a CSS class for each assigned role, followed by the hide. Here I have management hide, packaging hide, shipping hide, and retail hide.
Step 3
Hover over the info icon on your page's data table to get the component ID.
Step 4
Add the following code to the JavaScript tab of your page.
TB.render('component_ID', function(data) {
if ('{loggedInUser.Role}' === 'Management') {
$('.management').removeClass('hide');
} else if ('{loggedInUser.Role}' === 'Packaging') {
$('.packaging').removeClass('hide');
} else if ('{loggedInUser.Role}' === 'Shipping') {
$('.shipping').removeClass('hide');
} else if ('{loggedInUser.Role}' === 'Retail') {
$('.retail').removeClass('hide');
}
});
Remember to change the component ID as well as the roles.
Original Community Post:
https://community.tadabase.io/t/show-columns-based-on-the-users-role/1978
We'd love to hear your feedback.