cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid groupSortDirection returned, after setting enum to "NoSortDirection"

Former Member
0 Kudos

Hi, we are in process of creating an application to overwrite the grouping and sorting in a report. The application will remove all sort and group fields (using ReportAppServer.Controllers.SortController.Remove) then add back in all sorts. We want to set the sorting to "NoSortDirection". However, if we set it CrSortDirectionEnum.crSortDirectionNoSortOrder it failes with "no valid SortDirection".
Why?

  protected void SetSorts (Sorts Sorts, SortController controller )
  {
  foreach ( Sort sort in Sorts )
  {
  sort.Direction = CrSortDirectionEnum.crSortDirectionNoSortOrder;
  controller.Add( -1, sort );
  }
  }

Do i use the modifySortDirection function, instead of removing and adding the Sorts, I get an exception saying "I'm not allowed to change the SortField information"

Why can I set all other enum-values, but not the NoSortOrder?
Where is my error?

I would appreciate any help.

Thanks
Jessica

In use:
- SAP Crystal Reports for Visual Studio 2017
- Crystal Reports Version: 13.0.21.2533
- I'm using the in proc RAS API

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Jessica,

That is by design, if you don't want no sort then don't set it.

I noticed the same when I was testing:

Field f = (Field)rptClientDoc.DataDefController.DataDefinition.ResultFields.FindField("TestDon", CrystalDecisions.ReportAppServer.DataDefModel.CrFieldDisplayNameTypeEnum.crFieldDisplayNameName, CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleEnglish);
if (rptClientDoc.DataDefController.SortController.CanSortOn(f))
{
    Sort mySort = new Sort();
    mySort.Direction = CrSortDirectionEnum.crSortDirectionAscendingOrder;
    mySort.SortField = f;
    MessageBox.Show(rptClientDoc.DataDefController.SortController.CanSortOn(f).ToString());
    rptClientDoc.DataDefController.SortController.Add(-1, mySort);

    //test = (ISCRSort)boFieldObject;
    //test.Direction = CrSortDirectionEnum.crSortDirectionDescendingOrder;

    //try
    //{
    //    if (Formula.Name == "TestDon")
    //    {
    //        MysortController.add(CrSortDirectionEnum.crSortDirectionNoSortOrder, test);
    //        // if no sort then delete the sort and SAVE the report
    //        //rptClientDoc.SaveAs("don2.rpt", @"D:\Atest\swati\CrystalTest_3501213_2013", 0);
    //    }
    //}
    //catch (Exception ex)
    //{
    //    btnSQLStatement.Text = "ERROR: " + ex.Message;
    //}
}
else
{ }

Because there was a work around I never ask R&D to look into it...

Don

Answers (2)

Answers (2)

0 Kudos

Hy!

I have the same problem. Still no solution?

We are using Crystal Reports CRforVS13SP26_0-10010309.EXE.

Thank you!

Former Member
0 Kudos

Hi Don,

we sort our Data in our database, we dont need another sortorder.
That's the reason why I wanted to set it to "noSortDirection".

You said there is a workaround? How does it work?

Jessica