Disable hierarchy

Posted by: rscampini on 8 September 2017, 1:00 pm EST

  • Posted 8 September 2017, 1:00 pm EST

    Hi,


    I am binding the control to a dataset with some relations. I would like to use each sheet i create to only display the table it is bound to and not any of the child/parent tables, just disable the hierarchy functionality. now according to the support people, there is no option to do so directly, one has to disable the + sign on each line (which is not really possible in my case since i don't know when the number of line may change). It seems a bit odd that no option to disable something that must take time to create (create all the child sheets...) cannot be disabled. Has anyone had the same problem and maybe found a way around it?


     


    Many thanks

  • Replied 8 September 2017, 1:00 pm EST

    Hello,


    You can bind the SheetView object to the DataTable you want it to display instead of the entire DataSet. Then the child sheets would not be loaded into the Spread.

  • Replied 8 September 2017, 1:00 pm EST

    Hello,


    My reply is not correct for the main table. The relations will still map the rows even in the DataTable object, so the hierarchy will still show when binding that DataTable to the Spread. You would need to create a DataTable without the relations created in it. You can do this by cloning the DataTable and setting the DataSource of the Spread to the cloned DataTable.

     
    		Dim dt As DataTable = dt1.Clone
    Dim drClone As DataRow
    For Each drMain As DataRow In dt1.Rows
    drClone = dt.NewRow
    For i As Integer = 0 To dt.Columns.Count - 1
    drClone.Item(i) = drMain.Item(i)
    Next
    dt.Rows.Add(drClone)
    Next
    FpSpread1.Sheets(0).DataSource = dt
     
  • Replied 8 September 2017, 1:00 pm EST

    Hi,


     



    Thanks for the answer. Unfortunately, I cannot use any of the above as I need the relationships (i have several calculated columns in the dataset which I do not want to do in the grid as the object holding the dataset may be used in different applications and i want to keep all data manipulation in there). Cloning the table could work for display purposes but would not allow the user to change data in automatically in the dataset (which is what i need).


    The only solution i see is to use the SetRowExpandable, the only problem here being finding an event that will tell me when the number of row has changed. I use BindingSources to show the data (very convenient as it changes the views automatically for me when the user chooses a different record...) so i need to know when the grid is displaying something new to loop through each row and disable the +.


     

  • Replied 8 September 2017, 1:00 pm EST

    Hello,


    You can programatically write changes from the clone to the original DataTable. Or if you want to use the SetRowExpandable method, you can use the DataModel's Changed event. The type parameter passed into this event will tell you if rows are added or removed.

  • Replied 8 September 2017, 1:00 pm EST

    Hi,


    The event looks like the good solution for me. I'll try implementing that.


    Thanks for your help.

Need extra support?

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

Learn More

Forum Channels