Grouping - Lost Formatting

Posted by: bo-jangles on 8 September 2017, 2:32 pm EST

  • Posted 8 September 2017, 2:32 pm EST

    Hi,


    I've created columns in code and populated cells manually. Some of the cells have custom cell type (and Paint event), some have built in types but with some properties changed (e.g. number of decimal place in the numeric cell type).


    When I display data for the first time evertyhing is 100% okay. When I drag a column header to the group bar, the spread groups the data but none of my custom cell type Paint events fire and all cells are rendered using some sort of a default - none of the formatting I've specified works.


    I have noticed that Spread_Sheet1.RowsCount = 0 doesn't work either while sheet is grouped.


    What am I missing?


    Regards


    Bojan

  • Replied 8 September 2017, 2:32 pm EST

    Hi,


     Attached is a sample app. Just drag column A to the grouping bar.


    The app consists of this source code so it's probably easier to just copy and paste into the new form


    Public Class Form1
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            For i As Integer = 0 To 20
                FpSpread1_Sheet1.Cells(i, 0).Value = IIf(i Mod 2 = 0, "A", "B")
                FpSpread1_Sheet1.Cells(i, 1).CellType = New MyCellType
                FpSpread1_Sheet1.Cells(i, 1).Value = i
            Next
        End Sub
    End Class



    Public Class MyCellType : Inherits FarPoint.Win.Spread.CellType.GeneralCellType
        Public Overrides Sub PaintCell(ByVal g As System.Drawing.Graphics, ByVal r As System.Drawing.Rectangle, ByVal appearance As FarPoint.Win.Spread.Appearance, ByVal value As Object, ByVal isSelected As Boolean, ByVal isLocked As Boolean, ByVal zoomFactor As Single)
            MyBase.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor)
            g.DrawEllipse(New System.Drawing.Pen(Color.Red), r)
        End Sub
    End Class 


     


    it's VS2010 and Spread 5.3514.2008 for Windows Forms.


     I'm sure that this has to do something with the sheetview vs. data model but I'm not sure how to make my formatting work for both grouped and ungrouped view.


     Regards


     Bojan


    2010/12/grouping.zip
  • Replied 8 September 2017, 2:32 pm EST

    Hello Bojan,

    I was not able to replicate the issue at my end. Would you please provide me a sample which replicates the issue. Also Please let me know which build of Spread Win you are using.

     

    Regards,

    Subodh,

    Grapecity, Farpoint

  • Replied 8 September 2017, 2:32 pm EST

    Hello,

    I set the celltype in grouped event and ungrouped event and it all seems to be working fine.

     

    Thanks,

     

  • Replied 8 September 2017, 2:32 pm EST

    Hi,


    Could you please elaborate this a bit further. The real life sheet will have numerous rows and columns. I will populate the sheet manually using .Cells(row,col).value = method. Depending on the underlying data I might decide to use a custom cell type for individual cells. There is no group ungroup event happening at this stage.


    If client decides to group data the group event will fire bit what am I suppose to do then? It's not like in the Mickey Mouse example that I've sent you where all cells have the same type, in a real life scanario cells will have many diferrent custom / built in formats.


    Aslo, sheet.RowCount = 0, definetelly doesn't work when the sheet is grouped. The sheet is not emptied and the number of rows is not affected. If I do this before grouping, the result is as expected. Te sheet will contain no rows.


     Again, I'm certain that this has to do something with the underlying data model vs. what is displayed in the sheet. 


    For example you have a post that explains that when you group by a date cell the data in the underlying model is used to show value in the group bar and not what is displayed in the date cell. If you format a date cell like dd/MM/yyyy and then drag that cell to the group bar the date will be displayed in the  format that includes hours and minutes dd/MM/yyyy HH:MM:ssAM.


    This data model - data view relation seems to be fundamental to the spread functionality. Please do a proper research before you post an answer back.


    Regards


    Bojan 


     


     


     


     


     


     


     

  • Replied 8 September 2017, 2:32 pm EST

    Hello,

    This is an issue with the style model for the sheet is cleared of all rows when the sheet is first grouped. I have reported this issue as a bug to our QA team which should be fixed in our next maintenance release of Spread for Windows.The bug number is 99919651.

    Also after grouping rows, you should not change the column count and row count. The GroupDataModel does not support changing the column or row count. To add or remove columns or rows, you need to call the original data model methods. You can access the original data model using TargetModel property of the GroupDataModel class.

     

    Thanks,

     

  • Replied 8 September 2017, 2:32 pm EST

    Thank you very much.


    I'm looking forward for the next maintenenace release. Until then the group functionality won't work for me.


    Regards


    Bojan 


     


     

Need extra support?

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

Learn More

Forum Channels