Premmerce Documentation > Table or Grid > How to Set only Specific Roles can View a Column

About Premmerce

Introduction

Full Features

Installation

Prerequisite

Setup & Installation

Table or Grid

Basic Usage

Disable Column Sorting

Disable Column Export

Change Search Placeholder

Custom Column Template

Add Buttons to Action Column

Hyperlink Column Text

Specific Roles to View Column

Add or remove column

Filter column

CSS and JS

Edit Color

File validation

General

Password Validation

Bulk Import

Other

It’s easy. Let’s go! The steps:

  1. You can refer to /Helpers/TableConfig.cs > LoginHistoryTableConfig > UserRole in List<ColumnProperty> TableColumns

  2. Set IsVisibleForAllRoles to false

  3. Populate the RolesPermittedToView property with a list of roles allowed to view the column.

  4. 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 }
            };
    }