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