Hierarchy/databinding/Formula

Posted by: echernyak on 8 September 2017, 1:46 pm EST

  • Posted 8 September 2017, 1:46 pm EST

    I am using hierarchy spread with binding (similar to Hierarchy Sample in SpreadWEinDemo). If I want to display summary column in a parent view based on data in the child view what is the best way to do it? For example, if in SpreadWinDemo(Hierrachy app) I would like to display a column with a Total grade (per Student, per Class) which will based on Child table grades.


    Should I try to add a formula column (unbound) in a Parent view based on cells in child view?  If yes, how can I do that?


    Should I create "summary" fields in parent datatables, use binding and use some events to update data in the table when Child data changes. If yes, which events should I use?


     Thank you

  • Replied 8 September 2017, 1:46 pm EST

    Hello,

    As it is known that to set up hierarchical data display, you first create a data set to hold the
    relational data, then define the relations between the data, and finally, set
    the FarPoint Spread component to display the data as you want. Considering that you are aleady doing it, I would suggest you to use the second approach mentioned by you and trap the Change event of the control. Please note that Spread uses different views to display Child & Parent rows, so you can map the changes in one view to the other view.

    Thanks,

    Suresh

  • Replied 8 September 2017, 1:46 pm EST

    I was trying to utilize DataModel Changed event and I couldn't get it to work. I addes code below in SpreadWinDemoVb app (hierarchy.vb). If you look at implementation of dsdm2_Changed():  debug.priint always displays original value from Grades datatable (I tried AcceptChanges) but not the new one which triggered this event


    Dim WithEvents dsdm2 As FarPoint.Win.Spread.Model.DefaultSheetDataModel


    Public Sub SetChildViewStyle(ByVal sv As FarPoint.Win.Spread.SheetView)


    ....


    Case "Grades"


    'Selected the Grade Level


    'Change the column widths


    dsdm2 = sv.Models.Data


    ====


    Private Sub dsdm2_Changed(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.Model.SheetDataModelEventArgs) Handles dsdm2.Changed


    If e.Column < 0 Then


    Exit Sub


    End If


    Dim intDataRow As Integer


    'dsdm2.GetDataTable.AcceptChanges()


    intDataRow = dsdm2.GetDataRowFromModelRow(e.Row)


    Debug.Print(dsdm2.GetDataTable().Rows(intDataRow).Item(e.Column))


    End Sub


     


     

  • Replied 8 September 2017, 1:46 pm EST

    Hello,


    In this code, you are cheking the wrong row from the DataTable. Here is the correct code to get the changed data.


    Debug.Print(dsdm2.GetDataRow(e.Row).Item(e.Column))

Need extra support?

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

Learn More

Forum Channels