This is a migrated thread and some comments may be shown as answers.

How to add placeholder in empty node?

3 Answers 175 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Serg
Top achievements
Rank 1
Veteran
Serg asked on 19 Jan 2021, 12:20 PM

How to add placeholder in empty node? So that when added to a node, the placeholder disappears, and if the number of objects becomes zero again, it appears again.

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 Jan 2021, 12:50 PM
Hello, Serg, 

Usually, a RadTreeNode is represented with a text for the node:

No nodes in RadTreeView:

One node (with text) in RadTreeView:

One selected node (without text) in RadTreeView:

Could you please give us some more details about the expectations you have regarding this placeholder? What is the exact design that you are looking for? Would it be possible to provide a sample screenshot of the exact requirement that you are trying to achieve? Thus, we would better understanding of the precise requirement and think about an appropriate solution.

Thank you in advance for your cooperation. I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Serg
Top achievements
Rank 1
Veteran
answered on 20 Jan 2021, 02:42 PM
The placeholder appears only when the node is empty (there are no other nodes in it). And it disappears immediately if you add 1 node or more there.I give an example in the picture.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Jan 2021, 01:38 PM
Hello, Serg, 

Thank you for the provided clarification.

In order to show the expander for a node, this node should contain at least one child node. Hence, in the provided screenshot the "Search Folders" node actually has a RadTreeNode which text is "(Empty)".

One possible solution that I can suggest is to use the NodeFromatting event and customize the fore color (e.g. light gray) for the visual node element according to your custom requirements. Don't forget to reset the style settings for the rest of the nodes that don't meet the criteria for an empty node you have since RadTreeView uses virtualization. Additional information how to use the NodeFromatting event is available here: https://docs.telerik.com/devtools/winforms/controls/treeview/working-with-nodes/formatting-nodes 

Another approach that may fit your needs is to create a custom node element with one additional element that shows the text for the placeholder. Then, in the Synchronzie method you can control whether this custom placeholder element (e.g. a LightVisualElement) will be visible or not according to the requirements you have for the empty node. A sample example for constructing custom nodes is demonstrated in this tutorial:
https://docs.telerik.com/devtools/winforms/controls/treeview/working-with-nodes/custom-nodes 

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Treeview
Asked by
Serg
Top achievements
Rank 1
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Serg
Top achievements
Rank 1
Veteran
Share this question
or