Sort groups by another field

Stimulsoft Reports.WEB discussion
Post Reply
sbaxter
Posts: 17
Joined: Thu Apr 02, 2009 5:32 am

Sort groups by another field

Post by sbaxter »

Its posible to sort the report groups by other field that is not the group field? For example, I have a report that shows the invoices grouped by ClientId. The groups are ordered by the ClientId but I want to have the option to sort the groups (not the data) by the ClientName depending of a variable.

ClientId: 11 ClientName: Client B
Invoice 1
Invoice 2
Invoice 3
ClientId: 24 ClientName: Client A
Invoice 1
Invoice 2
Invoice 3

or by name

ClientId: 24 ClientName: Client A
Invoice 1
Invoice 2
Invoice 3
ClientId: 11 ClientName: Client B
Invoice 1
Invoice 2
Invoice 3


For the moment, I've created this method and called from the GroupHeader condition "{SortGroups()}":

Code: Select all

public string SortGroups()
{
    // sortByClientName is a dictionary variable
    if (sortByClientName)
        // Adding CLIENTID makes the groups unique because some clients have the same name
        return MYDATATABLE.CLIENTNAME + MYDATATABLE.CLIENTID;

    return MYDATATABLE.CLIENTID.ToString();
}

If I solved my problem why I'm asking? Well by 2 reasons, first is I avoid write code in the reports and I can't find a way to configure this from the designer.
Second, to share it with all.

Any sugestions?

Regards,

Scott.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Sort groups by another field

Post by Jan »

Hello Scott,

Yes it possible. At first you need remove sorting from group. Set SortDirection property of GrouppHeaderBand to None. After then set required sorting to Databand.

Thank you.
sbaxter
Posts: 17
Joined: Thu Apr 02, 2009 5:32 am

Sort groups by another field

Post by sbaxter »

Hi Jan,

I tryed that but without a luck, maybe I'm doing something wrong. The report shows only one group. I tryed with this:

* GroupHeader1
- Conditions=[No conditions]
- Sort Direction=None
* Data1
- Sort by "IIF(sortByClientName==true, MYDATATABLE.CLIENTNAME + MYDATATABLE.CLIENTID, MYDATATABLE.CLIENTID)"
- Then by "MYDATATABLE.DATE"

The invoices in the group are sorted by date.


Regards,

Scott.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Sort groups by another field

Post by Jan »

Hello Scott,

Please assign condition to GroupHeaderBand.

Thank you.

Post Reply