aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Parent-Childs hierarchy

Open hungdluit opened this issue 8 years ago • 1 comments

The idea is, I want to build the hierarchy after rendering. The component will know and easy to access its parent and child component by using Parent and Childrens property.

Is there a way to achieve this?

hungdluit avatar May 08 '18 02:05 hungdluit

I have a work-around, hope this helps someone try to address some issue.

 protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            if (CSHTMLHelper.PARENT == null)
            {
                CSHTMLHelper.PARENT = this;
            }

            Parent = CSHTMLHelper.PARENT;
            CSHTMLHelper.PARENT = this;

            if (Parent != null
                && Parent != this)
            {
                Parent.Childrens.Add(this);
            }

            base.BuildRenderTree(builder);           

            CSHTMLHelper.PARENT = Parent;
        }

hungdluit avatar May 08 '18 03:05 hungdluit