HI,
I have this list in razor and I would like to parse a parameter to disable a specific item
List<object> listdata = new List<object>();
listdata.Add(new
{
id = 1,
name = "Home",
hasChild = false,
expanded = false,
navigateUrl = "../Home",
disableItem = true
});
listdata.Add(new
{
id = 2,
hasChild = true,
expanded = false,
name = "Entrada"
});
listdata.Add(new
{
id = 201,
pid = 2,
name = "Entrada produção",
navigateUrl = "../EstoqueMovimenta/MenuProducaoEstoque"
});
listdata.Add(new
{
id = 202,
pid = 2,
name = "Entrada scrap",
navigateUrl = "../EstoqueMovimenta/MenuScrapEstoque"
});
listdata.Add(new
{
id = 3,
hasChild = false,
expanded = false,
name = "Pedido",
navigateUrl = "../Pedido/Index"
});
listdata.Add(new
{
id = 4,
hasChild = true,
expanded = false,
name = "Cadastros",
});
listdata.Add(new
{
id = 401,
pid = 4,
name = "Estoque",
navigateUrl = "../Estoque/index"
});
listdata.Add(new
{
id = 402,
pid = 4,
name = "Cliente",
navigateUrl = "../Cliente/index"
});
listdata.Add(new
{
id = 403,
pid = 4,
name = "Linha",
navigateUrl = "../Linha/index"
});
listdata.Add(new
{
id = 404,
pid = 4,
name = "Unidade",
navigateUrl = "../Unidade/index"
});
listdata.Add(new
{
id = 5,
name = "ADM",
hasChild = true,
expanded = false,
});
listdata.Add(new
{
id = 501,
pid = 5,
name = "Usuário",
hasChild = false,
expanded = false,
navigateUrl = "../User/ListUser"
});
}
<ejs-treeview id="listdata" enablePersistence="true">
<e-treeview-fields dataSource="listdata"
id="id"
parentId="pid"
cssClass="mytree"
text="name"
hasChildren="hasChild"
expanded="expanded"
navigateUrl="navigateUrl">
</e-treeview-fields>
</ejs-treeview>
Hi Roberto,
Greetings from Syncfusion support.
You are able to disable the required nodes in the TreeView component by setting the e-disable class in the datasource by using htmlAttributes for specific nodes within fields setting. Check the below code snippet.
|
@{ IDictionary<string, object> customAttribute = new Dictionary<string, object>(); ViewData["Title"] = "Home page"; List<object> listdata = new List<object>(); ... listdata.Add(new { id = 2, pid = 1, name = "New South Wales", customAttribute = new Dictionary<string, object>() { { "class", "e-disable" } } }); ... }
<div> <ejs-treeview id="listdata"> <e-treeview-fields dataSource="listdata" id="id" parentId="pid" text="name" hasChildren="hasChild" expanded="expanded" htmlAttributes="customAttribute"></e-treeview-fields> </ejs-treeview> </div> |
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/CoreTreeView-1065851756
For your reference, we have attached a sample. Please check the sample and get back to us if you need any further assistance.
Regards,
Indhumathy L
Hi,
I had to make an adjustment because the h ref was still active for the tag. Your example opens the way for other options I was needing.
Hi Roberto,
We are glad that you have resolved the query with a workaround. Please get back to us if you need any further assistance.
Regards,
Indhumathy L