Dynamically Sorting

Stimulsoft Reports.Flex discussion
Locked
Pete
Posts: 10
Joined: Sun Dec 26, 2010 5:09 pm
Location: Chicago, Illinois

Dynamically Sorting

Post by Pete »

How do you dynamically set the sorting of databands? Some of my reports will need to be sorted depending on what the user sorts. Is it possible to set what the report databands sort by when loading the report in flex?
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Dynamically Sorting

Post by Vladimir »

Hello,

This functionality is already implemented and will be available in the prerelease build on January 4. In the attached archive you can see an example with dynamic sorting of the report.

Thank you.
Attachments
762.Sample.zip
(282.95 KiB) Downloaded 685 times
Pete
Posts: 10
Joined: Sun Dec 26, 2010 5:09 pm
Location: Chicago, Illinois

Dynamically Sorting

Post by Pete »

Thanks! I'll wait until tomorrow to mess around with it=)
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Dynamically Sorting

Post by Vladimir »

We always glad to help you!

Thank you.
jorool
Posts: 44
Joined: Wed Dec 08, 2010 1:39 pm
Location: Brazil

Dynamically Sorting

Post by jorool »

Hello,

Can someone tell me how to sort databands by multiple fields from code correctly?
I'm trying this, without success:

Code: Select all

var banda:StiDataBand = reportButtons.report.getComponentByName("DataBand1") as StiDataBand;
//clear sorts
banda.sort = [];
if (condition) {
    banda.sort.push(["ASC", "{dados.maskCodigo}"]);
    banda.sort.push(["ASC", "{dados.numeroPedido}"]);
    banda.sort.push(["ASC", "{dados.numeroEntrega}"]);
} else {
    banda.sort.push(["ASC", "{dados.maskCodigo}"]);
    banda.sort.push(["ASC", "{dados.lote}"]);
    banda.sort.push(["ASC", "{dados.loteOrdem}"]);
}
Thank you.
jorool
Posts: 44
Joined: Wed Dec 08, 2010 1:39 pm
Location: Brazil

Dynamically Sorting

Post by jorool »

Hello

I found C# solution on "Support Center » Knowledgebase » How to change data sorting?".
It works fine.

Code: Select all

var banda:StiDataBand = reportButtons.report.getComponentByName("DataBand1") as StiDataBand;
banda.sort = new Array();
if (condition) {
    banda.sort.push("ASC");
    banda.sort.push("numeroPedido");
    banda.sort.push("ASC");
    banda.sort.push("numeroEntrega");
} else {
    banda.sort.push("ASC");
    banda.sort.push("lote");
    banda.sort.push("ASC");
    banda.sort.push("loteOrdem");
}
Thank you.
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Dynamically Sorting

Post by Vladimir »

Hello,

You can simplify your code:

Code: Select all

var banda: StiDataBand = reportButtons.report.getComponentByName("DataBand1") as StiDataBand;
if (condition)
  banda.sort = [
    "ASC",
    "numeroPedido",
    "ASC",
    "numeroEntrega"
  ];
else 
  banda.sort = [
    "ASC",
    "lote",
    "ASC",
    "loteOrdem"
  ];
Let us know if you need any additional help.

Thank you.
jakrzysztow
Posts: 18
Joined: Tue Aug 09, 2011 10:35 am

Re: Dynamically Sorting

Post by jakrzysztow »

Ok, so I find the band, set the sort...and nothing happens....so either I have the sort wrong and that's why nothing happens, or something else must be done to apply the sort?
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: Dynamically Sorting

Post by Vladimir »

Hello,

Then you need to re-build a report, for example:

Code: Select all

...
report.isRendered = false;
report.render();
report.show();
Thank you.
Locked