Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to define a sort? #139

Open
KouJinrun opened this issue Nov 28, 2023 · 2 comments
Open

How to define a sort? #139

KouJinrun opened this issue Nov 28, 2023 · 2 comments

Comments

@KouJinrun
Copy link

I want to define a sort in my crosstab(in some rows or some columns), and I find the method [public T setComparatorExpression(DRIExpression> comparatorExpression)] in net.sf.dynamicreports.report.builder.crosstab.AbstractCrosstabGroupBuilder. But I don't know how to use it, in other words how to creat a correct comparatorExpression. So can you tell me how to use it or are there any other methos easier to achieve the purpose. Thanks!

@jan-moxter
Copy link
Member

You can sort the data outside the report and than use

public CrosstabBuilder setDataPreSorted(Boolean dataPreSorted) {
getObject().getDataset().setDataPreSorted(dataPreSorted);
return this;
}
or use
public T orderBy(final CrosstabMeasureBuilder> measure) {
return orderBy(Expressions.orderBy(measure));
}

and the 
  final CrosstabMeasureBuilder<BigDecimal> openAmountMeasure = DynamicReports.ctab.measure("amount", "amount", BigDecimal.class, Calculation.SUM);

@KouJinrun
Copy link
Author

Thanks for your help! The first method can work. But when I try to use the second method, it reports an error as follows :
image
image
image
Is there something wrong with the way I'm using it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants