cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Grouping overwrite sorting

clthen66
Discoverer
0 Likes
772

I have an windows application which collect the parameter, grouping, and sorting info and pass it to another application which load the crystal report. Recently I updated the runtime engine to SP34 and a having issue with the grouping keeps overwrites the sorting data.

Please note that all references already updated to the latest version.

This is the code I used for sorting:

Dim reportClientDocument As ISCDReportClientDocument = reportDoc.ReportClientDocument
Dim dataDefController As DataDefController = reportClientDocument.DataDefController
Dim resultFields As Fields = dataDefController.DataDefinition.ResultFields
Dim sortField As Field = DirectCast(resultFields.FindField(fieldName, CrystalDecisions.ReportAppServer.DataDefModel.CrFieldDisplayNameTypeEnum.crFieldDisplayNameFormula, CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleEnglishUS), Field)
Dim sortController As SortController = dataDefController.SortController

If sortController.CanSortOn(sortField) Then
    Dim sort As ISCRSort = sortController.FindSort(sortField)
    If sort Is Nothing Then
        Dim newSort As New Sort With {
         .SortField = sortField,
         .Direction = sortDirection
        }

        Dim existingGroup As Sort = CType(sortController.FindSort(sortField), Sort)
        If existingGroup Is Nothing Then
            sortController.Add(sortLevel - 1, newSort)
            sortController.ModifySortDirection(sortLevel - 1, sortDirection)
        Else
            ModifySortDirection(reportClientDocument, fieldName, sortDirection)
        End If
    Else
        ModifySortDirection(reportClientDocument, fieldName, sortDirection)
    End If
End If<br>

Unfortunately, each time it's done adding all the sorting and moved to the next line of code, the grouping data replace everything on the sorting with whatever it had.

I ended up having to add the sorting data as part of the grouping, but that messed up all the formatting.

Did anyone have any idea what's happening and if there's any possible solution?

I've been stuck in this problem for days and tried so various things which ended up with the groups overwrite everything.

View Entire Topic
DonWilliams
Active Contributor
0 Likes

Hi Cynthia,

What happens if you try changing the sorting in CR Designer 2016 or 2020 in the same order as your code?

Code is based on the same rules as CR Designer so it may be something was changed in CRD.

I'll get R&D to have a quick look at this post and see if he can duplicate the problem.

Don