Skip to Content
avatar image
Former Member

Invalid groupSortDirection returned, after setting enum to "NoSortDirection"

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Mar 01 at 03:07 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 07 at 04:17 PM

    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

    Add comment
    10|10000 characters needed characters exceeded