Custom models.data and dragging and dropping

Posted by: kbj on 21 December 2018, 7:54 am EST

    • Post Options:
    • Link

    Posted 21 December 2018, 7:54 am EST

    I’d like to take advantage of the ability to use a custom worksheet data model and also continue using row drag drop.

    When I use a custom model based on the DefaultSheetDataModel, values stored in the sheet’s RowHeader cells are incorrectly moved after a row(s) drag.

    example:

  • Posted 21 December 2018, 7:54 am EST

    
    Imports FarPoint.Win.Spread
    Imports FarPoint.Win.Spread.Model
    
    Public Class Form1
        Private dm As classDm
        Private wb As FpSpread
        Private ws As SheetView
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
            wb = New FpSpread
            ws = New SheetView
            dm = New classDm
            dm.RowCount = 20
            dm.ColumnCount = 5
            ws.RowHeader.AutoText = HeaderAutoText.Blank
            ws.Models.Data = dm 'if this is commented out, dragging and dropping works
            ws.OperationMode = OperationMode.ExtendedSelect
            wb.Sheets.Add(ws)
            wb.AllowRowMove = True
            wb.AllowRowMoveMultiple = True
            wb.Dock = DockStyle.Fill
            Controls.Add(wb)
            ws.RowHeader.Columns(0).Width = 80
            For rowIndex = 5 To 15
                Dim rowTitle = New classRowTitle
                rowTitle.index = rowIndex
                ws.RowHeader.Cells(rowIndex, 0).Value = rowTitle
                ws.Cells(rowIndex, 0).Value = rowIndex
            Next
        End Sub
    End Class
    Public Class classDm
        Inherits DefaultSheetDataModel
    End Class
    Public Class classRowTitle
        Public index As Integer
        Public Overrides Function ToString() As String
            Return "Row:" & index.ToString
        End Function
    End Class
    
    
  • Posted 22 December 2018, 4:16 am EST - Updated 30 September 2022, 4:52 am EST

    Here are two examples of dragging rows.

    Note that the result of dragging works for the cells, not the row headers

  • Posted 23 December 2018, 8:58 pm EST

    Hi,

    You can handle RowDragMove event and set MoveContent to False:

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
        ...
    
        AddHandler wb.RowDragMove, AddressOf Workbook_RowDragMove
    End Sub
    
    Private Sub Workbook_RowDragMove(sender As Object, e As DragMoveEventArgs)
        e.MoveContent = False
    End Sub
    
    

    Regards,

    Jitender

  • Posted 24 December 2018, 1:36 am EST

    Hi Jitender,

    Thanks for your quick response. Your solution solves some of my problems. One problem is that RangeGroups don’t move with the row move as they do with the automatically loaded ws.Models.Data (which probably is as designed with the e.MoveContent = False). If I could get the new classDm to behave exactly as that automatically loaded ws.Models.Data, it would be great.

    Also, a RangeGroup added to sheet with the new classDm does not show up until the sheet is redrawn (is there a way to force a redraw?. I have to resize the sheet). Add a ws.AddRangeGroup(4, 5, True) to the above Form1_Load to see what I mean.

  • Posted 24 December 2018, 1:56 am EST

    On further investigation, RangeGroups don’t work at all in the above example. They display, but can’t be expanded or collapsed.

    There must be a simple way to have a custom data model that behaves exactly like the default data model.

  • Posted 25 December 2018, 9:39 pm EST

    Hi,

    We checked your code with previous builds, and it works correctly in Spread 10. So, we’ve escalated this as a bug to the development team [Internal Tracking ID: 268668]. We’ll let you know when we have more information to share with you.

    Thanks.

  • Posted 30 December 2018, 3:45 pm EST

    Hi,

    The fix for this issue will be available in SP1 update (April, 2019).

    Thanks,

    Jitender

  • Posted 12 May 2019, 4:30 am EST

    Using the .03 release, this problems persists. Any idea when the SP1 will actually ship and is this bug fixed?

  • Posted 12 May 2019, 5:35 pm EST

    Hi,

    The expected release date for SP1 is the end of May. This bug has been fixed in SP1 builds.

    Regards,

    Jitender

  • Posted 13 May 2019, 2:42 am EST

    Hi Jitender,

    I just wanted to make sure that Range grouping behaved the same in an inherited Data Model as it does with the DefaultSheetDataModel. This is important.

    Thanks,

    Kingman

  • Posted 13 May 2019, 3:50 pm EST

    Hi Kingman,

    I’ve created a case for you in S1 (https://supportone.componentone.com/home/casedetail/379347) so you can check for yourself if the bug is correctly fixed or not.

    Regards,

    Jitender

  • Posted 29 May 2019, 9:31 pm EST

    Hi Kingman,

    Spread SP1 is officially released now. You can download it from here: https://www.grapecity.com/download/spreadnet

    Thanks,

    Jitender

Need extra support?

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

Learn More

Forum Channels