Node background color selection issue

Hi there,

I have created tree table using go js. Here is my code Codepen Link

I have added borders using BorderedTreeLayout class (you can see it in the code)

Im using gray background color when any row is selected like below

I know my child level nodes have some space before the text in the first column.

My query here is that, is there a way I can make this entire horizontal row appear with background color?

Something like below (edited in paint)

Please suggest how can I achieve above result? or else please go ahead and do the changes in the code link I provided above.

Ah, so you don’t want to highlight a node, but the area covered by the cells which the node occupies. In a table you would say that you want to highlight the row. I suppose you will eventually also want to be able to highlight columns too, which could be implemented in a similar fashion.

Since you already have a “BANDS” singleton template that is used to draw the border around the whole table, the horizontal separator lines, and the vertical separator lines, I suggest that you add a Shape to that “BANDS” template whose purpose is to draw the desired rectangular highlight areas, one per row, presumably with a zero Shape.strokeWidth.

Just as the BorderedTreeLayout.commitLayers method specifies the Geometry of the “HORIZONTALS” Shape in order to draw horizontal lines, you could augment that method to look for the new Shape that you have added to the “BANDS” template. Let’s name it “ROWS”. Just as with the “HORIZONTALS” Shape, you would iterate over the vertexes. For each one that had a LayoutVertex.node and whose node was Part.isSelected, you would add a PathFigure specifying points defining a rectangle with the position and size that you want.

Hi Walter,
Thanks for the response.
Yes your understanding is correct but I dont need column selection only row selection is good enough.
If its not a big task for you can you please modify my code given in the link? I spent time and I tried the way you suggested but I could not figure out how to make it work.

Thanks in advance

The above does as Walter describes, adding a “ROWS” Shape to the “BANDS” template, and updating its Geometry by looping through the selected Nodes during commitLayers. The node templates now use a selectionChanged function to ensure the “ROWS” shape gets updated.

It worked thanks for the solution :)