Premmerce Documentation > Table or Grid > How to Set only Specific Roles can View a Column
About Premmerce
Installation
Table or Grid
CSS and JS
General
You can refer to /Helpers/TableConfig.cs
> LoginHistoryTableConfig
> UserRole
in List<ColumnProperty> TableColumns
Set IsVisibleForAllRoles
to false
Populate the RolesPermittedToView
property with a list of roles allowed to view the column.
Example:
To make the UserRole
column visible only to the Admin
role:
new ColumnProperty{ HeaderKey= nameof(LoginHistoryViewModel.UserRole), IsVisibleForAllRoles=false, RolesPermittedToView=new List<string?>(){"Admin" } }
To allow multiple roles (e.g., Admin
and Agent
):
RolesPermittedToView = new List<string?> { "Admin", "Agent" }
Full LoginHistoryTableConfig
example
public static class LoginHistoryTableConfig
{
public static List<ColumnProperty> TableColumns = new List<ColumnProperty>() {
new ColumnProperty{ HeaderKey= nameof(LoginHistoryViewModel.Username) },
new ColumnProperty{ HeaderKey= nameof(LoginHistoryViewModel.FullName) },
//This column will be displayed for admin only. It will be hidden from agents and customers.
new ColumnProperty{ HeaderKey= nameof(LoginHistoryViewModel.UserRole), **IsVisibleForAllRoles=false, RolesPermittedToView=new List<string?>(){"Admin" }** },
new ColumnProperty{ HeaderKey= nameof(LoginHistoryViewModel.LoginDateTime), ValueKey = nameof(LoginHistoryViewModel.IsoUtcLoginDateTime),IsDateTimeColumn = true }
};
}