Apply css to treeitems by level
hi,
is it possible to get one of these 2 options with the treeview control ? :
Option1
apply custom css to all nodes that have childrens (or the inverse)
Option2
apply custom css by level
thanks and good day .
SIGN IN To post a reply.
3 Replies
PR
Piramanayagam Ramakrishnan
Syncfusion Team
January 11, 2017 12:44 PM UTC
Hi Issam,
Thanks for contacting Syncfusion support.
We can achieve your requirement (“apply custom CSS to all nodes that have children’s”) in TreeView control from application level by using cssClass property. It sets the root CSS class for TreeView which allows to customize the appearance.
We can apply custom CSS to all nodes that have children based on the “.e-icon” class. This class is present in sibling element of a node which have children. We can also apply the custom CSS to nodes by level based on the li element “.e-item” class. Please refer to the below code example,
|
[Script]
$("#customtree").ejTreeView({
fields: { id: "id", parentId: "pid", text: "name", hasChild: "hasChild", dataSource: localData, expanded: "expanded" },
cssClass: "mytree", //apply custom css class to TreeView
});
[CSS]
<style>
/*apply custom css to all nodes that have children's*/
.mytree .e-text-wrap .e-icon + .e-text {
font-weight: bold;
}
/*apply custom css to first level*/
.mytree > ul > .e-item > .e-text-wrap .e-text {
color: brown;
}
/*apply custom css to second level*/
.mytree > ul > .e-item > ul > .e-item > .e-text-wrap .e-text {
color: darkmagenta;
}
</style>
|
For more details on the cssClass property, please refer to the help document link: https://help.syncfusion.com/api/js/ejtreeview#members:cssclass
For your reference, we have prepared a sample, it can be downloaded from the following location: http://jsplayground.syncfusion.com/fc4okefx
Please let us know whether the provided sample is helpful in achieving your requirement. If not, get back to us with more information.
Regards,
Piramanayagam R
IS
issam
January 11, 2017 02:34 PM UTC
this is exactly what i am looking for :)
thanks a lot .
PN
Preethi Nesakkan Gnanadurai
Syncfusion Team
January 12, 2017 06:08 AM UTC
Hi Issam,
Most welcome.
Please let us know if you need further assistance on this.
Regards,
Preethi
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
IS issam
- Jan 10, 2017 03:07 PM UTC
- Jan 12, 2017 06:08 AM UTC