Hi
In the sample the sidebar content is static and is defined in the mainlayout, how can i display a component on node click.
For example if I click the node "installation" I want the content of the counter component to be displayed as the side bar content.
Basically a replacement for the default navmenu which has rel='nofollow' hrefs to various components or pages.
<!-- sidebar element declaration -->
<SfSidebar HtmlAttributes="@HtmlAttribute" Width="290px" Target=".main-content" @ref="Sidebar" MediaQuery="(min-width:600px)" @bind-IsOpen="isOpen">
<ChildContent>
<div class="main-menu">
<div>
<SfTreeView CssClass="main-treeview" @ref="TreeView" ExpandOn="@Expand" TValue="TreeData">
<TreeViewEvents TValue="TreeData"></TreeViewEvents>
<TreeViewFieldsSettings Id="nodeId" Text="nodeText" IconCss="iconCss" DataSource="treedata" NavigateUrl="navigateUrl" HasChildren="hasChild" ParentID="pid">
</TreeViewFieldsSettings>
</SfTreeView>
</div>
</div>
</ChildContent>
</SfSidebar>
<!-- end of sidebar element -->
<!-- main-content declaration -->
<div class="main-content" id="main-text" style="height:100vh">
<div class="sidebar-content">
@Body
</div>
</div>
</div>
</div>
@code {
public class TreeData
{
public string nodeId { get; set; }
public string nodeText { get; set; }
public string iconCss { get; set; }
public bool hasChild { get; set; }
public string pid { get; set; }
public string navigateUrl { get; set; }
}
private List<TreeData> treedata = new List<TreeData>();
protected override void OnInitialized()
{
base.OnInitialized();
treedata.Add(new TreeData { nodeId = "01", nodeText = "Installation", iconCss = "icon-microchip icon", navigateUrl="/FetchData" });
treedata.Add(new TreeData { nodeId = "02", nodeText = "Deployment", iconCss = "icon-thumbs-up-alt icon", navigateUrl="/Counter" });
}
} |