Skip to content
Advertisement

Color show not properly in the js tree

I have a problem to get the color in the js tree. Below is my coding:

JavaScript

This is javascript:

JavaScript

My output cannot follow the number to present the color if I’ve added “$testing” variable word in the front of the number.Like below the picture:

Out2

Actually I want the output like below the picture. The color can show infront of number.

Out2

This is my working jsfiddle: https://jsfiddle.net/jv4k1f0s/1/

Hope someone can guide me how to solve it. Thanks.

Advertisement

Answer

To take the easy way out, you can change the position of text in span tag to First.

Example:

This is your data:

JavaScript

You can change position MasterName in text key to first, like this:

JavaScript

And after that, you need to replace this function:

JavaScript

To this:

JavaScript

Updated: You can keep your data template

Try use foreach loop like this:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement