Articles in this section
Category / Section

How to customize the ASP.NET Core TreeView selection and hover effects only for the text

6 mins read
This article explains the detailed steps followed to customize the ASP.NET Core TreeView selection and hover effects only on the text.

Step 1: Implement TreeView component using our getting started documentation.

Step 2: To achieve the background color being limited to the text while hovering over and selecting the TreeView node, you can utilize the help of the TreeView fullRowNavigable and fullRowSelect property by setting them to false. Additionally, you will need to add the following CSS customization for the TreeView component classes at your end.

[Index.cshtml]

<div class="control_wrapper">

    <ejs-treeview id="treedata" fullRowNavigable="false" fullRowSelect="false" allowMultiSelection="true">

            <e-treeview-fields dataSource="listdata" id="id" parentId="pid" text="name" hasChildren="hasChild" expanded="expanded" navigateUrl="navigateUrl"></e-treeview-fields>

    </ejs-treeview>

</div>


<style>

    /* Active and Hover styles for selected treeview item */

    #treedata.e-treeview:not(.e-fullrow-wrap) .e-list-item.e-active > .e-text-content .e-list-text,

    #treedata.e-treeview:not(.e-fullrow-wrap) .e-list-item.e-active.e-hover > .e-text-content .e-list-text {

        background-color: #0d6efd;

        border-color: #0d6efd;

    }

    /* Hover style for treeview item */

    #treedata.e-treeview:not(.e-fullrow-wrap) .e-list-item.e-hover > .e-text-content .e-list-text {

        background-color: #e9ecef;

        border-color: #e9ecef;

    }

    /* Icon color for collapsible and expandable tree nodes */

    #treedata.e-treeview .e-icon-collapsible::before, .e-treeview .e-icon-expandable::before {

        color: #6c757d;

    }

    /* Active, Focus and Hover styles for treeview items */

    #treedata.e-treeview:not(.e-fullrow-wrap) .e-list-item.e-active.e-node-focus > .e-text-content,

    #treedata.e-treeview:not(.e-fullrow-wrap) .e-list-item.e-active.e-hover > .e-text-content,

    #treedata.e-treeview:not(.e-fullrow-wrap) .e-list-item.e-active > .e-text-content,

    #treedata.e-treeview:not(.e-fullrow-wrap) .e-list-item.e-hover > .e-text-content,

    #treedata.e-treeview:not(.e-fullrow-wrap) .e-list-item.e-node-focus > .e-text-content {

        background-color:inherit;

        border: none;

    }

</style>

Screenshot:


Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied