cascading the column values in the parent to child in a hirarchy

Posted by: vishnupriya on 8 September 2017, 2:12 pm EST

  • Posted 8 September 2017, 2:12 pm EST

    Hi,


    I have a hiearchical view in 3 levels. And we have one STATUS column. If we have changed/entered the STATUS column value in the parent rows then this value need to cascade down to all the child rows.


    If I entered the STATUS value in the firt level row then the value need to cascade down to the second level and third level child rows. If we entered the STATUS value in the second level row then the value need to cascade down to the third level children.


    Can some one let me know How I can do this? This need to be worked if the rows are not expanded also.


    Thanks,
    Vishnupriya

  • Replied 8 September 2017, 2:12 pm EST

    Hello,

    I am not very much clear with your requirement. It seems that you want if you update any Column in the first row(parent row) , then the related child row for that column should be updated with the same entry.If this is correct the you may achieve the same by capturing Spread's Change Event for that Specific Column(STATUS), and you will need to check if the value updated was in the parent view or first child view. If this is not what you want please let me know what is the requirement exactly.

     

    Thanks, 

  • Replied 8 September 2017, 2:12 pm EST

    Thanks for the reply.


    Actaully We have 3 level hirarchial data.(Please note there is no root row). And we have status column, if we changed this value in the 1st level the value will be cascade to the below levels( 2nd & 3rd level). If we changed the value in the 2nd level the value need to cascade to 3rd level rows. If we changed in 3rd value there is no need to cascade.


    For this I have done the below code in teh cell_change event.


                FarPoint.Win.Spread.SheetView ssChild;
                FarPoint.Win.Spread.SheetView ssGrandChild;           
                int i, j, ParentRow;
                string StatusNew;                      
                   
                  if (e.Column == 2)
                  {
                        StatusNew= e.View.Sheets[0].ActiveCell.Value.ToString();
                        ParentRow = e.Row;  


                                             
                           if (e.View.Sheets[0].GetChildView(ParentRow, 0) != null)
                                ssChild = e.View.Sheets[0].GetChildView(ParentRow, 0);
       else
                                 ssChild = null;


                            if (ssChild != null)
                            {
                               
                                for (i = 0; i < ssChild.RowCount; i++)
                                {
                                  
                                        ssChild.SetValue(i, 2, StatusNew);
                                        if (ssChild.GetChildView(i, 0) != null)
                                        {
                                            ssGrandChild = ssChild.GetChildView(i, 0);
                                        }
                                        else
                                        {
                                            ssGrandChild = null;
                                        }


                                        if (ssGrandChild != null)
                                        {
                                            for (j = 0; j < ssGrandChild.RowCount; j++)
                                                ssGrandChild.SetValue(j, 2, StatusNew);
                                        }
                                   
                                }


       }


    It is working fine if we changethe first level data. But if i changed the data in the 3rd level. the below statement causing problem as it doen't have any childs.


    if (e.View.Sheets[0].GetChildView(ParentRow, 0) != null)
                                ssChild = e.View.Sheets[0].GetChildView(ParentRow, 0);


    Same way if We are chnging the values in the 2nd level the below one causing problem as we don't have grandchild


    if (ssChild.GetChildView(i, 0) != null)
                                            ssGrandChild = ssChild.GetChildView(i, 0);


    So can you please let me know How I can solve this problem.


     Thanks,


    Vishnupriya 


     



                          

  • Replied 8 September 2017, 2:12 pm EST

    Hello,

    In order to get the information about the third level of hierarchy you may use the code like below,

    ssGrandChild= FpSpread1.ActiveSheet.GetChildView(0, 0).GetChildView(0, 0)

     

    I hope it will help you.

    Thanks, 

     

     

     

     

     

  • Replied 8 September 2017, 2:12 pm EST

    Hi,


    Thanks for the information. 


    But I want to wirte the generic code for all three levels in one method under cell_change event.


    If any change in the status column in the master level, this value will be cascade to next 2 leavels.
    If any change in the second level it should be cascade to the next one level.
    If any change in the third level it should updated in that row only. No need of cascading here.


    Thanks,
    Vishnupriya


     


     

  • Replied 8 September 2017, 2:12 pm EST

    Hello,

    You may have to loop through all the SheetViews and set the text to as same as of the parent Row. While the Child is  the GrandChild you may only set the Text for first ChildRow to the GrandChild row Text.

    Thanks,

     

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels