ASP.NET Identity roles and SF Controls

Hi, have you got any examples for best practices how to use ASP.NET Identity roles to control permissions of SF components.
For instance, what's the best way to set the EditSettings of a sf-grid based on the roles of the current user and/or set the visibility of toolbar items accoring to identity roles.

kind regards

3 Replies

BS Balaji Sekar Syncfusion Team December 3, 2020 12:35 PM UTC

Hi Gert, 
 
Before proceeding your requirement we need to confirm that you want to achieve your query in EJ2 Grid component or EJ1 Grid control so, please ensure to us that will help to validate further. 
 
Regards, 
Balaji Sekar  



GW gwoo December 3, 2020 01:22 PM UTC

I'm using EJ1 grid,

cheers, Gert


PK Padmavathy Kamalanathan Syncfusion Team December 4, 2020 03:28 PM UTC

Hi Gert, 
 
Thanks for contacting Syncfusion Forums. 
 
Query: what's the best way to set the EditSettings of a sf-grid based on the roles of the current user and/or set the visibility of toolbar items accoring to identity roles. 
 
From your query we understand that you need to dynamically change the editSettings and toolbar visibility of the Grid based on the Server end value. We have achieved your requirement, by setting the EditSettings and Toolbar properties based on the flag value as shown in the below code. Similarly you can change them dynamically based on your server end value. 
 
Please check the below code snippet, 
  
  
@{  
    var edit = new EditSettings(); 
    var tool = new ToolbarSettings(); 
    if (flag) 
    { 
        edit.AllowEditing = true; 
        edit.AllowAdding = true; 
        edit.AllowDeleting = true; 
        tool.ShowToolbar = true; 
        tool.ToolbarItems = new List<string>() { "edit", "add", "delete", "search" }; 
    } 
    else 
    { 
        edit.AllowEditing = false; 
        edit.AllowAdding = false; 
        edit.AllowDeleting = false; 
        tool.ShowToolbar = true; 
        tool.ToolbarItems = new List<string>() { "search"}; 
    } 
  
} 
@{Html.EJ().Grid<Object>("Grid") 
          ------------ 
       .EditSettings(edit).ToolbarSettings(tool) 
        .Columns(col =>  { 
          ------------ 
         }).Render(); } 
  
 
 
Kindly get back to us for further assistance. 
 
Regards, 
Padmavathy Kamalanathan 


Loader.
Up arrow icon